Repository navigation
fix(event): omit non-finite event tags from conversion events - #646
Open
Alex Castillo González (pcbeingused33) wants to merge 1 commit into
Open
Alex Castillo González (pcbeingused33) wants to merge 1 commit into
Alex Castillo González (pcbeingused33) wants to merge 1 commit into
Conversation
Event tags holding NaN or Infinity were copied into the conversion event as is. Gson and org.json refuse to serialize those values, so the exception surfaced on the dispatcher thread and the whole batch was dropped. Leave such tags out when the event is built, as is already done for the reserved value tag and for attributes.
This branch has not been deployed
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.
Summary
track()copies the caller's event tags into the conversion event unchanged. A tag whose value isDouble.NaNor±Infinity(under any key other than the reservedvalue) has no JSON representation, andGsonSerializerandJsonSerializer(org.json) throw on it (IllegalArgumentException/JSONException). WithAsyncHttpEventHandlerthat exception is raised when the log event body is built on the dispatcher thread, where onlyIOExceptionandURISyntaxExceptionare handled, so the whole batch (up to 10 events, possibly from other users) is lost. This only shows up when Jackson is not on the classpath, becauseDefaultJsonSerializerprefers Jackson, which writesNaNwithout throwing.Root cause
EventFactory.createVisitor(ConversionEvent)callssetTags(conversionEvent.getTags())with no validation.EventTagUtils.getNumericValuealready rejects NaN/Infinity, but only for the reservedvaluekey, andAttributesUtil.isValidNumberdoes the same for attributes; other event tags had no equivalent check.Fix
EventFactorynow leaves out event tags whose value is a non-finiteDoubleorFloatwhen it builds the conversion event, and logs a warning naming the tag. The caller's map is not modified, and the same map instance is passed through when there is nothing to remove. Finite numbers and all other tag types are unchanged.Test
EventFactoryTest.createConversionEventOmitsNonFiniteEventTagstracks a conversion with NaN,Double.POSITIVE_INFINITYandFloat.NEGATIVE_INFINITYtags next to valid ones and checks that only the valid tags reach the event, that the input map is untouched, and that a defaultGsoncan serialize the resulting batch. It fails before the change and passes after it.This change was prepared with the help of an AI coding assistant.