Skip to content

fix(event): omit non-finite number event tags from conversion events - #413

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

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

Conversation

@pcbeingused33

Copy link
Copy Markdown

Summary

  • Event tags whose value is a Float NaN, Infinity or -Infinity are now left out of the conversion event, with a warning that names the tag.
  • Revenue and numeric value are read from the filtered tags.

EventFactory copied event tags into the payload unchanged. A non-finite value then made event.params.to_json raise JSON::GeneratorError at dispatch time, so after the retries the whole batch was dropped, including other users' events. With revenue: Float::NAN or Float::INFINITY it was worse: get_revenue_value raised FloatDomainError while the batch was being built, outside the dispatch rescue, and the processing thread exited. Attributes already reject non-finite numbers.

The hash passed in by the caller is not modified, and only top-level tag values are checked.

Test plan

  • New regression spec in spec/event/event_factory_spec.rb (fails on master with FloatDomainError, passes with the fix).
  • With a two-user BatchEventProcessor batch and a dispatcher that calls to_json, nothing was delivered on master for {'x' => Float::NAN} or {'revenue' => Float::INFINITY}; both visitors are delivered with the fix.
  • bundle exec rubocop is clean on the changed files. The full rspec run has two failures that also happen on master.

Issues

  • None filed.

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

This branch has not been deployed

No deployments
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