Skip to content
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: addl meta unmarshal deep obj #1245

Merged
merged 4 commits into from
Feb 4, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions pkg/client/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,20 @@ func (a *actionListenerImpl) Actions(ctx context.Context) (<-chan *Action, <-cha
var additionalMetadata map[string]string

if assignedAction.AdditionalMetadata != nil {
err := json.Unmarshal([]byte(*assignedAction.AdditionalMetadata), &additionalMetadata)

if err != nil {
// Try to unmarshal as map[string]string first
var rawMap map[string]interface{}
if err := json.Unmarshal([]byte(*assignedAction.AdditionalMetadata), &rawMap); err != nil {
// If that fails, try to unmarshal as a single string
a.l.Error().Err(err).Msgf("could not unmarshal additional metadata")
continue
} else {
// Only keep string values from the map
additionalMetadata = make(map[string]string)
for k, v := range rawMap {
if strVal, ok := v.(string); ok {
additionalMetadata[k] = strVal
}
}
}
}

Expand Down
Loading