You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we enter this switch, len(path) == 0. However, if none of the conditions match (e.g. data is an int) then it falls through to path[0] which will panic with index out of range. I recommend adding a default case to the switch or after the switch to return an informative error.
if len(path) == 0 {
switch data.(type) {
case string:
return data.(string)
case float64:
return data.(float64)
case bool:
return data.(bool)
case nil:
return nil
case []interface{}:
return data
case map[string]interface{}:
return data
}
}
switch path[0].(type) {
The text was updated successfully, but these errors were encountered:
data was actually an int for me, and I modified the library as described to work around it. Perhaps I was using the library in a way not intended, but either way the fix won't do any harm.
No, I no longer have access to the codebase, and we switched away from this library in the end.
My gut feeling is the "object tree" in the interface{} was actually an int, and this was allowed by our data model but not by your library. Would that make sense?
If we enter this switch, len(path) == 0. However, if none of the conditions match (e.g. data is an int) then it falls through to path[0] which will panic with index out of range. I recommend adding a default case to the switch or after the switch to return an informative error.
The text was updated successfully, but these errors were encountered: