Skip to content

fix: metricUnavailableValue parameter not working in Datadog scaler#7241

Merged
JorTurFer merged 5 commits intokedacore:mainfrom
matchan26:fix-datadog-scaler-metric-unavailable-value
Nov 19, 2025
Merged

fix: metricUnavailableValue parameter not working in Datadog scaler#7241
JorTurFer merged 5 commits intokedacore:mainfrom
matchan26:fix-datadog-scaler-metric-unavailable-value

Conversation

@matchan26
Copy link
Contributor

@matchan26 matchan26 commented Nov 9, 2025

Problem

The UseFiller flag was not being set when metricUnavailableValue was configured, causing KEDA to always throw an error when Datadog returns empty metrics, regardless of the configured fallback value.

Root cause: The Validate() method only set UseFiller = false when FillValue == 0, but had no logic to set UseFiller = true for non-zero values. Since Go initializes bool to false, the flag remained false in all cases.

Solution

This fix properly sets the UseFiller flag by checking whether metricUnavailableValue is explicitly configured in TriggerMetadata, rather than relying on the value itself.

Key changes:

  • Set UseFiller = true in validateAPIMetadata() when metricUnavailableValue exists in TriggerMetadata
  • Set UseFiller = true in validateClusterAgentMetadata() when metricUnavailableValue exists in TriggerMetadata
  • Remove the incorrect UseFiller logic from Validate() method (responsibility moved to validation functions)

Why this approach:

  • Fixes the reported bug (non-zero values now work correctly)
  • Handles the case where users explicitly set metricUnavailableValue: "0"
  • Properly distinguishes "not configured" from "explicitly set to 0"
  • Restores backward compatibility with KEDA 2.17.2 behavior
  • Follows the existing pattern used for other derived values like HpaMetricName

Behavior After Fix

metricUnavailableValue UseFiller FillValue Behavior when series is empty
Not set false 0 ❌ Error thrown (expected)
"0" true 0 ✅ Returns 0
"1" true 1 ✅ Returns 1
"-1" true -1 ✅ Returns -1

Testing

Added comprehensive unit tests in TestDatadogMetadataValidateUseFiller that verify:

  • UseFiller = false when metricUnavailableValue is not configured
  • UseFiller = true when metricUnavailableValue is explicitly set to "0"
  • UseFiller = true and correct FillValue for positive, negative, and decimal values

Checklist

Fixes #7238 - the metricUnavailableValue parameter being non-functional in the Datadog scaler (bug introduced in KEDA 2.18.0).

Relates to #

The UseFiller flag was not being set correctly when metricUnavailableValue
was configured. This fix distinguishes between 'not configured' and
'explicitly set to 0' by checking TriggerMetadata directly.

Changes:
- Set UseFiller in validateAPIMetadata() when metricUnavailableValue exists
- Set UseFiller in validateClusterAgentMetadata() when metricUnavailableValue exists
- Remove UseFiller logic from Validate() (responsibility moved to validate functions)
- Update tests to verify UseFiller behavior with various values including 0

This allows users to explicitly set metricUnavailableValue to 0 and have
it work as a fallback value, while still erroring when not configured.

Fixes kedacore#7238

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>
@matchan26 matchan26 requested a review from a team as a code owner November 9, 2025 04:25
@keda-automation keda-automation requested a review from a team November 9, 2025 04:25
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

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 November 9, 2025 04:25
@snyk-io
Copy link

snyk-io bot commented Nov 9, 2025

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

Status Scanner 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.

@rickbrouwer
Copy link
Member

rickbrouwer commented Nov 11, 2025

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

@matchan26
Copy link
Contributor Author

@rickbrouwer
Sorry about that - I used the PR template as is and forgot to remove checks that weren't relevant to this scope. Fixed now - does this look better?

@rickbrouwer
Copy link
Member

@rickbrouwer Sorry about that - I used the PR template as is and forgot to remove checks that weren't relevant to this scope. Fixed now - does this look better?

Thanks. I'll wait voor reviewing until this PR is reviewed by @kedacore/keda-core-datadog-notification

Copy link
Contributor

@arapulido arapulido left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

I have added a comment that we are missing a similar test to cover validateClusterAgentMetadata .

Once we add it, I think we are good to go

Updated TestDatadogMetadataValidateUseFiller to test both validateAPIMetadata()
and validateClusterAgentMetadata() code paths. This ensures that the UseFiller
flag is correctly set in both integration modes.

Test cases now cover:
- API mode: 5 test cases (not configured, 0, positive, negative, decimal)
- Cluster Agent mode: 5 test cases (same variations)

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>
@keda-automation keda-automation requested a review from a team November 16, 2025 03:45
@matchan26 matchan26 requested a review from arapulido November 16, 2025 04:10
@rickbrouwer
Copy link
Member

rickbrouwer commented Nov 16, 2025

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

Comment on lines +257 to +259
if _, ok := config.TriggerMetadata["metricUnavailableValue"]; ok {
meta.UseFiller = true
}
Copy link
Member

Choose a reason for hiding this comment

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

Isn't there any other way to detect if is has been defined than checking TriggerMetadata map? I'd prefer to not access it manually to avoid problems if the name changes or so. Maybe declaring FillValue as *float64 without default value and filling the default later as well as UseFiller does the same (I'm not sure tbh).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. I agree that the current implementation relies on hardcoded strings, which could be brittle if parameter names change. I will try changing the type to *float64 to see if that resolves your concern while maintaining the current logic structure.

Copy link
Contributor

@arapulido arapulido left a comment

Choose a reason for hiding this comment

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

LGTM

@rickbrouwer rickbrouwer added the merge-conflict This PR has a merge conflict label Nov 18, 2025
…metric-unavailable-value

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>
@keda-automation keda-automation requested review from a team November 18, 2025 14:10
@rickbrouwer rickbrouwer removed the merge-conflict This PR has a merge conflict label Nov 18, 2025
@matchan26 matchan26 force-pushed the fix-datadog-scaler-metric-unavailable-value branch from 129909b to de26c03 Compare November 18, 2025 15:23
Changed FillValue from float64 to *float64 to distinguish between
'not configured' (nil) and 'explicitly set to any value including 0'.

This addresses reviewer feedback about avoiding direct TriggerMetadata
access and improves type safety and refactoring resistance.

Changes:
- FillValue type changed from float64 to *float64 with optional tag
- validateAPIMetadata checks nil instead of TriggerMetadata map
- validateClusterAgentMetadata checks nil instead of TriggerMetadata map
- Dereference FillValue when returning fallback value (2 locations)
- Update tests to handle pointer type with proper nil checks

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>
@matchan26 matchan26 force-pushed the fix-datadog-scaler-metric-unavailable-value branch from de26c03 to c1426d8 Compare November 18, 2025 15:29
@matchan26 matchan26 requested a review from JorTurFer November 18, 2025 15:57
@rickbrouwer
Copy link
Member

rickbrouwer commented Nov 19, 2025

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

@rickbrouwer rickbrouwer added the ok-to-merge This PR can be merged label Nov 19, 2025
@JorTurFer JorTurFer merged commit 4a8f895 into kedacore:main Nov 19, 2025
25 checks passed
@matchan26 matchan26 deleted the fix-datadog-scaler-metric-unavailable-value branch November 21, 2025 13:09
@JorTurFer JorTurFer mentioned this pull request Dec 7, 2025
31 tasks
JorTurFer pushed a commit to JorTurFer/keda that referenced this pull request Dec 8, 2025
…edacore#7241)

* fix: metricUnavailableValue parameter not working in Datadog scaler

The UseFiller flag was not being set correctly when metricUnavailableValue
was configured. This fix distinguishes between 'not configured' and
'explicitly set to 0' by checking TriggerMetadata directly.

Changes:
- Set UseFiller in validateAPIMetadata() when metricUnavailableValue exists
- Set UseFiller in validateClusterAgentMetadata() when metricUnavailableValue exists
- Remove UseFiller logic from Validate() (responsibility moved to validate functions)
- Update tests to verify UseFiller behavior with various values including 0

This allows users to explicitly set metricUnavailableValue to 0 and have
it work as a fallback value, while still erroring when not configured.

Fixes kedacore#7238

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* test: cover both API and ClusterAgent modes in UseFiller test

Updated TestDatadogMetadataValidateUseFiller to test both validateAPIMetadata()
and validateClusterAgentMetadata() code paths. This ensures that the UseFiller
flag is correctly set in both integration modes.

Test cases now cover:
- API mode: 5 test cases (not configured, 0, positive, negative, decimal)
- Cluster Agent mode: 5 test cases (same variations)

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* refactor: use pointer type for FillValue to avoid TriggerMetadata access

Changed FillValue from float64 to *float64 to distinguish between
'not configured' (nil) and 'explicitly set to any value including 0'.

This addresses reviewer feedback about avoiding direct TriggerMetadata
access and improves type safety and refactoring resistance.

Changes:
- FillValue type changed from float64 to *float64 with optional tag
- validateAPIMetadata checks nil instead of TriggerMetadata map
- validateClusterAgentMetadata checks nil instead of TriggerMetadata map
- Dereference FillValue when returning fallback value (2 locations)
- Update tests to handle pointer type with proper nil checks

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

---------

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>
JorTurFer pushed a commit to JorTurFer/keda that referenced this pull request Dec 8, 2025
…edacore#7241)

* fix: metricUnavailableValue parameter not working in Datadog scaler

The UseFiller flag was not being set correctly when metricUnavailableValue
was configured. This fix distinguishes between 'not configured' and
'explicitly set to 0' by checking TriggerMetadata directly.

Changes:
- Set UseFiller in validateAPIMetadata() when metricUnavailableValue exists
- Set UseFiller in validateClusterAgentMetadata() when metricUnavailableValue exists
- Remove UseFiller logic from Validate() (responsibility moved to validate functions)
- Update tests to verify UseFiller behavior with various values including 0

This allows users to explicitly set metricUnavailableValue to 0 and have
it work as a fallback value, while still erroring when not configured.

Fixes kedacore#7238

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* test: cover both API and ClusterAgent modes in UseFiller test

Updated TestDatadogMetadataValidateUseFiller to test both validateAPIMetadata()
and validateClusterAgentMetadata() code paths. This ensures that the UseFiller
flag is correctly set in both integration modes.

Test cases now cover:
- API mode: 5 test cases (not configured, 0, positive, negative, decimal)
- Cluster Agent mode: 5 test cases (same variations)

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* refactor: use pointer type for FillValue to avoid TriggerMetadata access

Changed FillValue from float64 to *float64 to distinguish between
'not configured' (nil) and 'explicitly set to any value including 0'.

This addresses reviewer feedback about avoiding direct TriggerMetadata
access and improves type safety and refactoring resistance.

Changes:
- FillValue type changed from float64 to *float64 with optional tag
- validateAPIMetadata checks nil instead of TriggerMetadata map
- validateClusterAgentMetadata checks nil instead of TriggerMetadata map
- Dereference FillValue when returning fallback value (2 locations)
- Update tests to handle pointer type with proper nil checks

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

---------

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>
JorTurFer pushed a commit to JorTurFer/keda that referenced this pull request Dec 8, 2025
…edacore#7241)

* fix: metricUnavailableValue parameter not working in Datadog scaler

The UseFiller flag was not being set correctly when metricUnavailableValue
was configured. This fix distinguishes between 'not configured' and
'explicitly set to 0' by checking TriggerMetadata directly.

Changes:
- Set UseFiller in validateAPIMetadata() when metricUnavailableValue exists
- Set UseFiller in validateClusterAgentMetadata() when metricUnavailableValue exists
- Remove UseFiller logic from Validate() (responsibility moved to validate functions)
- Update tests to verify UseFiller behavior with various values including 0

This allows users to explicitly set metricUnavailableValue to 0 and have
it work as a fallback value, while still erroring when not configured.

Fixes kedacore#7238

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* test: cover both API and ClusterAgent modes in UseFiller test

Updated TestDatadogMetadataValidateUseFiller to test both validateAPIMetadata()
and validateClusterAgentMetadata() code paths. This ensures that the UseFiller
flag is correctly set in both integration modes.

Test cases now cover:
- API mode: 5 test cases (not configured, 0, positive, negative, decimal)
- Cluster Agent mode: 5 test cases (same variations)

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* refactor: use pointer type for FillValue to avoid TriggerMetadata access

Changed FillValue from float64 to *float64 to distinguish between
'not configured' (nil) and 'explicitly set to any value including 0'.

This addresses reviewer feedback about avoiding direct TriggerMetadata
access and improves type safety and refactoring resistance.

Changes:
- FillValue type changed from float64 to *float64 with optional tag
- validateAPIMetadata checks nil instead of TriggerMetadata map
- validateClusterAgentMetadata checks nil instead of TriggerMetadata map
- Dereference FillValue when returning fallback value (2 locations)
- Update tests to handle pointer type with proper nil checks

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

---------

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>
Signed-off-by: Jorge Turrado <jorge.turrado@mail.schwarz>
JorTurFer added a commit that referenced this pull request Dec 8, 2025
* fix: Correct parse error ActiveMQ (#7245)

Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
Signed-off-by: Jorge Turrado <jorge.turrado@mail.schwarz>

* fix: metricUnavailableValue parameter not working in Datadog scaler (#7241)

* fix: metricUnavailableValue parameter not working in Datadog scaler

The UseFiller flag was not being set correctly when metricUnavailableValue
was configured. This fix distinguishes between 'not configured' and
'explicitly set to 0' by checking TriggerMetadata directly.

Changes:
- Set UseFiller in validateAPIMetadata() when metricUnavailableValue exists
- Set UseFiller in validateClusterAgentMetadata() when metricUnavailableValue exists
- Remove UseFiller logic from Validate() (responsibility moved to validate functions)
- Update tests to verify UseFiller behavior with various values including 0

This allows users to explicitly set metricUnavailableValue to 0 and have
it work as a fallback value, while still erroring when not configured.

Fixes #7238

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* test: cover both API and ClusterAgent modes in UseFiller test

Updated TestDatadogMetadataValidateUseFiller to test both validateAPIMetadata()
and validateClusterAgentMetadata() code paths. This ensures that the UseFiller
flag is correctly set in both integration modes.

Test cases now cover:
- API mode: 5 test cases (not configured, 0, positive, negative, decimal)
- Cluster Agent mode: 5 test cases (same variations)

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* refactor: use pointer type for FillValue to avoid TriggerMetadata access

Changed FillValue from float64 to *float64 to distinguish between
'not configured' (nil) and 'explicitly set to any value including 0'.

This addresses reviewer feedback about avoiding direct TriggerMetadata
access and improves type safety and refactoring resistance.

Changes:
- FillValue type changed from float64 to *float64 with optional tag
- validateAPIMetadata checks nil instead of TriggerMetadata map
- validateClusterAgentMetadata checks nil instead of TriggerMetadata map
- Dereference FillValue when returning fallback value (2 locations)
- Update tests to handle pointer type with proper nil checks

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

---------

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>
Signed-off-by: Jorge Turrado <jorge.turrado@mail.schwarz>

* Fix ScaledObject pause behavior when HPA doesn't exist (#7233)

When a ScaledObject has the paused annotation set before the HPA is
created, the controller would fall through and create the HPA, ignoring
the pause annotation.

The fix writes the paused status to etcd immediately before stopping
the scale loop or deleting the HPA. This prevents race conditions where
concurrent reconciles triggered by HPA deletion would not see the paused
status and perform redundant operations.

The key insight is to establish the paused state in etcd BEFORE any
operations that trigger new reconciles, ensuring subsequent reconciles
see the paused status and exit early.

This solution follows the approach suggested by @rickbrouwer.

Fixes #7231

Signed-off-by: nusmql <nusmql@gmail.com>
Signed-off-by: Jorge Turrado <jorge.turrado@mail.schwarz>

* fix: use TriggerError when all ScaledJob triggers fail (#7205)

Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
Signed-off-by: Jorge Turrado <jorge.turrado@mail.schwarz>

* Fix transfer-hpa-ownership panic when hpa name not provided (#7260)

* chore: renormalize line endings

Signed-off-by: James Williams <jamesleighwilliams@gmail.com>

* fix: nil pointer when transfer-hpa-ownership is true but hpa name not specified (#7254)

Signed-off-by: James Williams <jamesleighwilliams@gmail.com>

* update changelog

Signed-off-by: James Williams <jamesleighwilliams@gmail.com>

* revert vendor changes

Signed-off-by: James Williams <jamesleighwilliams@gmail.com>

---------

Signed-off-by: James Williams <jamesleighwilliams@gmail.com>
Signed-off-by: Jorge Turrado <jorge.turrado@mail.schwarz>

* fix: restore HPA behavior when paused-scale-in/out annotation is deleted (#7291)

When paused-scale-in or paused-scale-out annotation is deleted (not set
to "false") and the corresponding selectPolicy (scaleDown.selectPolicy
or scaleUp.selectPolicy) is not explicitly set in the ScaledObject spec,
the HPA's SelectPolicy remains stuck at "Disabled" instead of being
restored.

This occurs even if other behavior fields like policies or
stabilizationWindowSeconds are defined - only an explicit selectPolicy
value triggers the update.

Root cause: DeepDerivative treats nil as "unset" and considers it a
subset of any value, so DeepDerivative(nil, Disabled) returns true,
preventing the HPA update.

Fix: Add explicit DeepEqual check for Behavior field, following the
existing pattern used for Metrics length check.

test: add e2e test for paused-scale-in annotation removal

Signed-off-by: Dima Shevchuk <dshedimon@gmail.com>
Signed-off-by: Jorge Turrado <jorge.turrado@mail.schwarz>

* refactor: remove unused scaledObjectMetricSpecs variable (#7292)

* refactor: remove unused scaledObjectMetricSpecs variable

Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>

* update CHANGELOG.md

Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>

---------

Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>
Signed-off-by: Jorge Turrado <jorge.turrado@mail.schwarz>

* fix: handle requestScaleLoop error in ScaledObject controller (#7273)

* fix: handle requestScaleLoop error in ScaledObject controller

Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>

* chore: update CHANGELOG for PR #7273

Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>

---------

Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge.turrado@mail.schwarz>

* bump actions and go version (#7295)

* bump actions and go version

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* bump deps

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* update pkgs

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* update tools

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* .

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix test

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix lint

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* update setup-go to use go.mod version

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* add nolint to exclude pulsar issues

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix devenv

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix codeql

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix splunk test

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* include job in links

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* update to ubuntu-slim some runners

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* Update apis/keda/v1alpha1/scaledobject_webhook_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>

* Update .github/workflows/scorecards.yml

Co-authored-by: Jan Wozniak <wozniak.jan@gmail.com>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>

---------

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jan Wozniak <wozniak.jan@gmail.com>
Signed-off-by: Jorge Turrado <jorge.turrado@mail.schwarz>

* update changelog

Signed-off-by: Jorge Turrado <jorge.turrado@mail.schwarz>

---------

Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
Signed-off-by: Jorge Turrado <jorge.turrado@mail.schwarz>
Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>
Signed-off-by: nusmql <nusmql@gmail.com>
Signed-off-by: James Williams <jamesleighwilliams@gmail.com>
Signed-off-by: Dima Shevchuk <dshedimon@gmail.com>
Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Co-authored-by: Rick Brouwer <rickbrouwer@gmail.com>
Co-authored-by: Matchan <fenethtool@gmail.com>
Co-authored-by: nusmql <nusmql@gmail.com>
Co-authored-by: James Williams <jamesleighwilliams@gmail.com>
Co-authored-by: Dima Shevchuk <dshedimon@gmail.com>
Co-authored-by: Kai Udo <76635578+u-kai@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jan Wozniak <wozniak.jan@gmail.com>
alt-dima pushed a commit to alt-dima/keda that referenced this pull request Dec 13, 2025
…edacore#7241)

* fix: metricUnavailableValue parameter not working in Datadog scaler

The UseFiller flag was not being set correctly when metricUnavailableValue
was configured. This fix distinguishes between 'not configured' and
'explicitly set to 0' by checking TriggerMetadata directly.

Changes:
- Set UseFiller in validateAPIMetadata() when metricUnavailableValue exists
- Set UseFiller in validateClusterAgentMetadata() when metricUnavailableValue exists
- Remove UseFiller logic from Validate() (responsibility moved to validate functions)
- Update tests to verify UseFiller behavior with various values including 0

This allows users to explicitly set metricUnavailableValue to 0 and have
it work as a fallback value, while still erroring when not configured.

Fixes kedacore#7238

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* test: cover both API and ClusterAgent modes in UseFiller test

Updated TestDatadogMetadataValidateUseFiller to test both validateAPIMetadata()
and validateClusterAgentMetadata() code paths. This ensures that the UseFiller
flag is correctly set in both integration modes.

Test cases now cover:
- API mode: 5 test cases (not configured, 0, positive, negative, decimal)
- Cluster Agent mode: 5 test cases (same variations)

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* refactor: use pointer type for FillValue to avoid TriggerMetadata access

Changed FillValue from float64 to *float64 to distinguish between
'not configured' (nil) and 'explicitly set to any value including 0'.

This addresses reviewer feedback about avoiding direct TriggerMetadata
access and improves type safety and refactoring resistance.

Changes:
- FillValue type changed from float64 to *float64 with optional tag
- validateAPIMetadata checks nil instead of TriggerMetadata map
- validateClusterAgentMetadata checks nil instead of TriggerMetadata map
- Dereference FillValue when returning fallback value (2 locations)
- Update tests to handle pointer type with proper nil checks

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

---------

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>
Signed-off-by: Dmitriy Altuhov <altuhovd@gmail.com>
tangobango5 pushed a commit to tangobango5/keda that referenced this pull request Dec 22, 2025
…edacore#7241)

* fix: metricUnavailableValue parameter not working in Datadog scaler

The UseFiller flag was not being set correctly when metricUnavailableValue
was configured. This fix distinguishes between 'not configured' and
'explicitly set to 0' by checking TriggerMetadata directly.

Changes:
- Set UseFiller in validateAPIMetadata() when metricUnavailableValue exists
- Set UseFiller in validateClusterAgentMetadata() when metricUnavailableValue exists
- Remove UseFiller logic from Validate() (responsibility moved to validate functions)
- Update tests to verify UseFiller behavior with various values including 0

This allows users to explicitly set metricUnavailableValue to 0 and have
it work as a fallback value, while still erroring when not configured.

Fixes kedacore#7238

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* test: cover both API and ClusterAgent modes in UseFiller test

Updated TestDatadogMetadataValidateUseFiller to test both validateAPIMetadata()
and validateClusterAgentMetadata() code paths. This ensures that the UseFiller
flag is correctly set in both integration modes.

Test cases now cover:
- API mode: 5 test cases (not configured, 0, positive, negative, decimal)
- Cluster Agent mode: 5 test cases (same variations)

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* refactor: use pointer type for FillValue to avoid TriggerMetadata access

Changed FillValue from float64 to *float64 to distinguish between
'not configured' (nil) and 'explicitly set to any value including 0'.

This addresses reviewer feedback about avoiding direct TriggerMetadata
access and improves type safety and refactoring resistance.

Changes:
- FillValue type changed from float64 to *float64 with optional tag
- validateAPIMetadata checks nil instead of TriggerMetadata map
- validateClusterAgentMetadata checks nil instead of TriggerMetadata map
- Dereference FillValue when returning fallback value (2 locations)
- Update tests to handle pointer type with proper nil checks

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

---------

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>
tangobango5 pushed a commit to tangobango5/keda that referenced this pull request Feb 13, 2026
…edacore#7241)

* fix: metricUnavailableValue parameter not working in Datadog scaler

The UseFiller flag was not being set correctly when metricUnavailableValue
was configured. This fix distinguishes between 'not configured' and
'explicitly set to 0' by checking TriggerMetadata directly.

Changes:
- Set UseFiller in validateAPIMetadata() when metricUnavailableValue exists
- Set UseFiller in validateClusterAgentMetadata() when metricUnavailableValue exists
- Remove UseFiller logic from Validate() (responsibility moved to validate functions)
- Update tests to verify UseFiller behavior with various values including 0

This allows users to explicitly set metricUnavailableValue to 0 and have
it work as a fallback value, while still erroring when not configured.

Fixes kedacore#7238

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* test: cover both API and ClusterAgent modes in UseFiller test

Updated TestDatadogMetadataValidateUseFiller to test both validateAPIMetadata()
and validateClusterAgentMetadata() code paths. This ensures that the UseFiller
flag is correctly set in both integration modes.

Test cases now cover:
- API mode: 5 test cases (not configured, 0, positive, negative, decimal)
- Cluster Agent mode: 5 test cases (same variations)

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

* refactor: use pointer type for FillValue to avoid TriggerMetadata access

Changed FillValue from float64 to *float64 to distinguish between
'not configured' (nil) and 'explicitly set to any value including 0'.

This addresses reviewer feedback about avoiding direct TriggerMetadata
access and improves type safety and refactoring resistance.

Changes:
- FillValue type changed from float64 to *float64 with optional tag
- validateAPIMetadata checks nil instead of TriggerMetadata map
- validateClusterAgentMetadata checks nil instead of TriggerMetadata map
- Dereference FillValue when returning fallback value (2 locations)
- Update tests to handle pointer type with proper nil checks

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>

---------

Signed-off-by: Hiroki Matsui <fenethtool@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-merge This PR can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: metricUnavailableValue parameter on datadog-scaler is non-functional in KEDA 2.18.1

4 participants