fix(validation): guard against nil TolerationSeconds in ValidateApplicationFailover#7689
fix(validation): guard against nil TolerationSeconds in ValidateApplicationFailover#7689A69SHUBHAM wants to merge 1 commit into
Conversation
Signed-off-by: A69SHUBHAM <spacekrai0@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request improves the robustness of the application failover validation logic by ensuring that optional pointer fields are safely checked before access. By adding defensive nil checks, the code becomes more resilient when invoked in contexts where default values from CRDs might not be applied. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds a nil check for TolerationSeconds in ValidateApplicationFailover to prevent a potential nil pointer dereference panic when validating application failover behavior. A corresponding unit test case has also been added to verify this scenario. There are no review comments, and I have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR makes ValidateApplicationFailover more defensive by avoiding a nil-pointer dereference when DecisionConditions.TolerationSeconds is unset, aligning its behavior with other optional pointer fields validated in the same function.
Changes:
- Add a nil guard before dereferencing
DecisionConditions.TolerationSecondsduring validation. - Add a unit test to ensure nil
TolerationSecondsdoes not error or panic.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/util/validation/validation.go | Adds a nil check before validating TolerationSeconds to prevent dereference panics. |
| pkg/util/validation/validation_test.go | Adds coverage for the nil TolerationSeconds case to prevent regression. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7689 +/- ##
==========================================
- Coverage 42.06% 42.06% -0.01%
==========================================
Files 879 879
Lines 54831 54831
==========================================
- Hits 23067 23066 -1
Misses 30020 30020
- Partials 1744 1745 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What does this PR do?
This PR adds a nil check before dereferencing
DecisionConditions.TolerationSecondsinValidateApplicationFailover.Although the CRD currently provides a default value for this field, the validation function can also be invoked directly where the field may still be nil. This change makes the validation more defensive and consistent with the handling of other optional pointer fields in the same function.
In addition, this PR adds a unit test covering the nil
TolerationSecondscase to prevent regressions.Fixes #7688
Does this PR introduce a user-facing change?