Skip to content

fix(datadog grok): don't panic on NaN in keyvalue filter - #1990

Merged
pront merged 2 commits into
mainfrom
tess.neau/grok-keyvalue-nan
Oct 13, 2026
Merged

pront merged 2 commits into
mainfrom
tess.neau/grok-keyvalue-nan

Conversation

@tessneau

@tessneau tessneau commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The keyvalue grok filter panics when a value is an unquoted NaN, so an ordinary log line like ratio=NaN crashes whatever is calling parse_grok/parse_groks:

panicked at src/datadog/grok/filters/keyvalue.rs:289:44:
not a float: FloatIsNan

parse_number uses nom's double, which also accepts nan (case-insensitive). NaN is never integral, so it ends up in NotNan::new(v).expect("not a float").

The fix turns that expect into a recoverable parse error, so NaN falls through to the string parser and keeps its original text. Infinities are unaffected since NotNan accepts them, so inf, Infinity and overflowing values like 1e999 still parse as floats.

How did you test this PR?

Added parse_value unit tests and an end-to-end parse_grok test covering NaN/nan/NAN, including the = delimiter form, plus inf/Infinity/±1e999 to pin the existing float behavior. The NaN tests reproduced the panic before the fix.

Does this PR include user-facing changes?

  • Yes. Please add a changelog fragment based on
    our guidelines.
  • No. A maintainer will apply the "no-changelog" label to this PR.

Checklist

References

N/A

nom's `double` accepts `nan`, `inf` and `infinity` and overflows large
exponents to infinity, so an unquoted value like `ratio=NaN` reached the
`NotNan::new(v).expect(..)` in `parse_number` and panicked. Reject
non-finite values there so they fall through to the string parser.

Generated with Claude Opus 5.5
@tessneau
tessneau requested a review from a team as a code owner October 12, 2026 11:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T11:51:30.223420Z 17be491 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 30cd12d7b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/datadog/grok/filters/keyvalue.rs Outdated

@datadoghq-integration datadoghq-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

Non-finite values produce a recoverable parse error, allowing the existing string fallback to preserve their original text while leaving finite-number parsing unchanged.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 30cd12d

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Vector compatibility advisory

This check tests whether Vector can update to the VRL version in this PR without additional changes. Dependency changes can make that update significantly harder. If the required Vector changes are reasonable, you can ignore this advisory. Review the workflow run for details.

Infinities were never the problem since `NotNan` accepts them, so keep
parsing `inf`, `infinity` and overflowing values like `1e999` as floats
and only fall back to a string for NaN.

Generated with Claude Opus 5.5
@tessneau tessneau changed the title fix(datadog grok): don't panic on non-finite numbers in keyvalue filter fix(datadog grok): don't panic on NaN in keyvalue filter Oct 12, 2026
@pront
pront added this pull request to the merge queue Oct 13, 2026
Merged via the queue into main with commit 73aa49e Oct 13, 2026
26 of 27 checks passed
@pront
pront deleted the tess.neau/grok-keyvalue-nan branch October 13, 2026 13:39
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.

4 participants