Merged
Conversation
This ensures we don't have a regression in this area. Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
This dependency is unmaintained and has recently been archived. The
function we used is equivalent to:
```go
import "reflect"
func TryConvertToMarshalMap(value any) any {
valueMeta := reflect.ValueOf(value)
switch valueMeta.Kind() {
case reflect.Array, reflect.Slice:
arrayLen := valueMeta.Len()
converted := make([]any, arrayLen)
for i := range arrayLen {
converted[i] = TryConvertToMarshalMap(valueMeta.Index(i).Interface())
}
return converted
case reflect.Map:
converted := make(map[string]any)
keys := valueMeta.MapKeys()
for _, keyMeta := range keys {
strKey, isString := keyMeta.Interface().(string)
if !isString {
continue
}
val := valueMeta.MapIndex(keyMeta).Interface()
converted[strKey] = TryConvertToMarshalMap(val)
}
return converted
default:
return value
}
}
```
So, all it does is replace `map` types with `map[string]any` and skip
keys, which are not of type string. However, `DeepCopyWithTemplate`
already does this with the only difference being that it passes
`len(keys)` as a capacity.
Moreover, `ConvertToMarshalMap` does not return an error, if one passes
an object of type `map`. So, the extra error check was redundant as
well.
In other words, omitting this function call does not affect behaviour.
Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
e6b5902 to
7db29e0
Compare
TheMeier
approved these changes
Nov 23, 2025
siavashs
approved these changes
Nov 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This dependency is unmaintained and has recently been archived. The function we used is equivalent to:
So, all it does is replace
maptypes withmap[string]anyand skip keys, which are not of type string. However,DeepCopyWithTemplatealready does this with the only difference being that it passeslen(keys)as a capacity.Moreover,
ConvertToMarshalMapdoes not return an error, if one passes an object of typemap. So, the extra error check was redundant as well.In other words, omitting this function call does not affect behaviour.
The new extension of the unit test passes with and without the removal of
trivago.The PR here is related, but seems address additional issues: #4083