-
Notifications
You must be signed in to change notification settings - Fork 3
fix: Preserve types when decoding records [sc-143811] #114
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -520,8 +520,14 @@ func decodeMsg(dec *msgpack.Decoder, tag string) (Message, error) { | |
| return out, fmt.Errorf("msgpack unmarshal event time: %w", err) | ||
| } | ||
|
|
||
| // Create a decoder that preserves number types (int64 vs float64) | ||
| // instead of converting all numbers to float64 like the default msgpack.Unmarshal | ||
| recordDecoder := msgpack.NewDecoder(bytes.NewReader(entry[1])) | ||
| // Configure decoder to preserve exact number types instead of converting to float64 | ||
| recordDecoder.UseLooseInterfaceDecoding(false) | ||
|
|
||
| var record map[string]any | ||
| if err := msgpack.Unmarshal(entry[1], &record); err != nil { | ||
| if err := recordDecoder.Decode(&record); err != nil { | ||
|
Comment on lines
+523
to
+530
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't this only for Go output plugins?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm yeah upon further investigation this isn't the cause of the behavior I'm seeing when testing the json processing as http_sink doesn't use this. May as well fix this here tho. |
||
| return out, fmt.Errorf("msgpack unmarshal event record: %w", err) | ||
| } | ||
|
|
||
|
|
||
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.
unrelated to you but i dont understand the code above this at all. in the event of an error, it looks like we do a lot of stuff w/o any side effects and then return an error in all paths.
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.
Hmm yeah that seems like a bug. It tries to decode the time, then has a couple fallback ways of decoding it but returns an error regardless of if the fallbacks succeed.