Skip to content

Handle NaN result from Prometheus#7522

Open
tcp13equals2 wants to merge 6 commits intokedacore:mainfrom
tcp13equals2:issue-7475-fix-prometheus-metric-value-nan
Open

Handle NaN result from Prometheus#7522
tcp13equals2 wants to merge 6 commits intokedacore:mainfrom
tcp13equals2:issue-7475-fix-prometheus-metric-value-nan

Conversation

@tcp13equals2
Copy link
Copy Markdown

@tcp13equals2 tcp13equals2 commented Mar 6, 2026

This PR seeks to address #7475.

When a Prometheus query is used for obtaining a scaler value the existing code will handle an Inf value being returned. However, if Prometheus returns a NaN this is not explicitly handled.

As a consequence, the NaN is parsed into a float64 and passed back for use in further evaluations.

This PR simply adds an additional test to ensure that NaN and Inf responses are handled in the same manner. This can result in arithmetic overflows and bogus keda_scaler_metrics_value being calculated.

Checklist

  • I have verified that my change is according to the deprecations & breaking changes policy
  • Tests have been added (if applicable)
  • Ensure make generate-scalers-schema has been run to update any outdated generated files
  • Changelog has been updated and is aligned with our changelog requirements, only when the change impacts end users
  • Commits are signed with Developer Certificate of Origin (DCO - learn more)

Fixes #7475

@tcp13equals2 tcp13equals2 requested a review from a team as a code owner March 6, 2026 00:50
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 6, 2026

Thank you for your contribution! 🙏

Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected.

While you are waiting, make sure to:

  • Add an entry in our changelog in alphabetical order and link related issue
  • Update the documentation, if needed
  • Add unit & e2e tests for your changes
  • GitHub checks are passing
  • Is the DCO check failing? Here is how you can fix DCO issues

Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient.

Learn more about our contribution guide.

@keda-automation keda-automation requested a review from a team March 6, 2026 00:50
@snyk-io
Copy link
Copy Markdown

snyk-io bot commented Mar 6, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Signed-off-by: Andrew Hall <[email protected]>
Signed-off-by: Andrew Hall <[email protected]>
@rickbrouwer
Copy link
Copy Markdown
Member

rickbrouwer commented Mar 6, 2026

/run-e2e prometheus
Update: You can check the progress here

Co-authored-by: Rick Brouwer <[email protected]>
Signed-off-by: Andrew Hall <[email protected]>
@tcp13equals2 tcp13equals2 requested a review from rickbrouwer March 6, 2026 08:01
@keda-automation keda-automation requested review from a team and removed request for rickbrouwer March 6, 2026 08:01
@rickbrouwer
Copy link
Copy Markdown
Member

rickbrouwer commented Mar 6, 2026

/run-e2e prometheus
Update: You can check the progress here

@rickbrouwer rickbrouwer enabled auto-merge (squash) March 6, 2026 08:28
@rickbrouwer rickbrouwer added the Awaiting/2nd-approval This PR needs one more approval review label Mar 6, 2026
@keda-automation keda-automation requested a review from a team March 25, 2026 02:20
@rickbrouwer
Copy link
Copy Markdown
Member

rickbrouwer commented Mar 25, 2026

/run-e2e prometheus
Update: You can check the progress here

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

Labels

Awaiting/2nd-approval This PR needs one more approval review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prometheus metric value does not handle NaN result

2 participants