Skip to content

fix(event): omit event tags that cannot be serialized to JSON - #463

Open
Alex Castillo González (pcbeingused333) wants to merge 1 commit into
optimizely:masterfrom
pcbeingused333:fix/non-serializable-event-tags
Open

Alex Castillo González (pcbeingused333) wants to merge 1 commit into
optimizely:masterfrom
pcbeingused333:fix/non-serializable-event-tags

Conversation

@pcbeingused333

Copy link
Copy Markdown

Summary

Track copies the caller's event tags into the conversion event unchanged. A tag with no JSON representation (a NaN or ±Inf float, also when nested in a map or slice, or a func/chan) makes json.Marshal fail for the whole log event. QueueEventDispatcher treats that as a dispatch failure: it retries, gives up, and leaves the event at the head of its queue. Every later flush starts from that same event, so no later impression or conversion is sent.

Root cause

createConversionEvent assigns eventTags without checking them. HTTPRequester.Post returns the marshal error, and QueueEventDispatcher.flushEvents only removes an event after a successful dispatch. value was affected too: getTagValue accepts NaN, so it was also copied into Conversion.Value.

Fix

Tags that cannot be marshalled are left out of the conversion event, with a warning naming each one. revenue and value are read from the filtered tags. The caller's map is not modified, and the same map instance is passed through when there is nothing to remove. Serializable tags are unchanged.

Test

TestCreateConversionEventOmitsUnserializableEventTags covers NaN, ±Inf, a nested NaN and a func next to valid tags, and checks that the resulting batch marshals. It fails before the change and passes after it. go test ./pkg/event/ ./pkg/client/ passes.

This change was prepared with the help of an AI coding assistant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant