Skip to content

fix: guard nil pointer dereference in customScalingStrategy.GetEffectiveMaxScale#7817

Open
Fedosin wants to merge 1 commit into
kedacore:mainfrom
Fedosin:fix/nil-pointer-custom-scaling-strategy
Open

fix: guard nil pointer dereference in customScalingStrategy.GetEffectiveMaxScale#7817
Fedosin wants to merge 1 commit into
kedacore:mainfrom
Fedosin:fix/nil-pointer-custom-scaling-strategy

Conversation

@Fedosin

@Fedosin Fedosin commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

customScalingStrategy.GetEffectiveMaxScale unconditionally dereferences CustomScalingQueueLengthDeduction (*int32) without a nil guard. The field is declared with omitempty in the CRD spec, so it is nil whenever a ScaledJob is created with scalingStrategy.strategy: custom and customScalingRunningJobPercentage set, but customScalingQueueLengthDeduction omitted. When the controller reaches the replica calculation path, it panics.

This PR adds nil guards for both pointer fields in GetEffectiveMaxScale, treating nil as zero (consistent with how other optional fields are handled). A regression test is included that exercises the exact configuration that triggers the panic.

Checklist

  • When introducing a new scaler, I agree with the scaling governance policy
  • 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
  • A PR is opened to update our Helm chart (repo) (if applicable, ie. when deployment manifests are modified)
  • A PR is opened to update the documentation on (repo) (if applicable)
  • Commits are signed with Developer Certificate of Origin (DCO - learn more)

Fixes #7798

Relates to #

…iveMaxScale

When a ScaledJob uses custom scaling strategy but omits
customScalingQueueLengthDeduction (valid since the field is *int32 with
omitempty), the controller panics on nil dereference. Add nil guards for
both pointer fields, treating nil as zero. Add a regression test that
exercises the nil deduction path.

Fixes kedacore#7798

Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>
@Fedosin Fedosin requested a review from a team as a code owner June 2, 2026 08:48
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

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.

@snyk-io

snyk-io Bot commented Jun 2, 2026

Copy link
Copy Markdown

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.

@keda-automation keda-automation requested a review from a team June 2, 2026 08:48
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.

bug: nil pointer dereference in customScalingStrategy when customScalingQueueLengthDeduction is omitted

1 participant