-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 unmarshalling of CreateDatabaseUserMode #49995
Conversation
@@ -2253,8 +2253,23 @@ func (h CreateDatabaseUserMode) encode() (string, error) { | |||
func (h *CreateDatabaseUserMode) decode(val any) error { | |||
var str string | |||
switch val := val.(type) { | |||
case int32: | |||
return trace.Wrap(h.setFromEnum(val)) | |||
case int64: |
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.
Why do we need to handle so many distinct types? Do we really expect inputs to vary this much?
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.
@codingllama Frankly, I don't know; I think that only floats would do, but I noticed that the other type (CreateHostUserMode
) has it defined this way, so I decided to follow it to maintain consistency.
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.
I think if you decode from json it'll always be a float64, so I found the other types curious. Technically it doesn't hurt so I won't block you for this.
@codingllama I also changed the other test cases around for consistency. |
This is required to support this field in the new role editor, since data returned from
/webapi/yaml/stringify
contains numeric enum values. When fed intoPUT /webapi/roles:name
, it then resulted in an error.