-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(model): Don't deserialize option values as Id
's if option type is String
#2190
fix(model): Don't deserialize option values as Id
's if option type is String
#2190
Conversation
Can you add a test for this case so it does not happen again in the future? |
twilight-model/src/application/interaction/application_command/option.rs
Outdated
Show resolved
Hide resolved
twilight-model/src/application/interaction/application_command/option.rs
Outdated
Show resolved
Hide resolved
@suneettipirneni Sorry, it seems that my suggestion did not work after all. Testing locally with the latest commit resulted in the following error: Otherwise this looks good. |
This reverts commit 85a1a20.
No worries, I've reverted the commit. |
Now that things might get deserialized into an allocated The variant This might be a topic for a subsequent new issue. Edit: Scratch that, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer to #2190 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a small nit-pick if you don't mind.
Because of the way
ValueEnvelope
is declared it automatically puts a higher precedence on deserializing to anId
rather than aString
.This behavior is desired because currently, the deserialization of option values doesn't take the
kind
of the option JSON into account. So if an option actually is a snowflake type it would be serialized as such instead of becoming aString
. This, however, does not account for situations where the string is a parseable Id, but is supposed to be represented as aString
regardless.As a result, this PR removes
ValueEnvelope::Id
. This means that means we initially deserialize any non-boolean or non-numeric values asString
s. Later on, when checking against the optionkind
we disambiguate the previously deserialized string and parse into the appropriateId
corresponding to thekind
.Closes #2178