Skip to content

fix: FeatureFlag update validation bad state#790

Merged
beeme1mr merged 5 commits into
open-feature:mainfrom
Y0sh1dk:fix/validation-bug
Jan 5, 2026
Merged

fix: FeatureFlag update validation bad state#790
beeme1mr merged 5 commits into
open-feature:mainfrom
Y0sh1dk:fix/validation-bug

Conversation

@Y0sh1dk

@Y0sh1dk Y0sh1dk commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

This PR

Fixes an issue where FeatureFlag CR update validation is validating the old object, not the new object. This results in FeatureFlag CRs getting into a bad state that cannot be recovered from without disabling the validation and fixing the CR.

Changes

  • Validate on newObj instead of oldObj for FeatureFlag updates
  • Add tests that would catch a regression

How to test

Before:

  • Create a valid FeatureFlag CR
  • Update it to be invalid (passes validating webhook since we were checking oldObj)
  • FeatureFlag CR is now in a bad state and cannot be updated again

After:

  • Create a valid FeatureFlag CR
  • Attempt to update it to be invalid (fails as expected)

Signed-off-by: Yosiah de Koeyer <dev@yosiahdekoeyer.dev>
Signed-off-by: Yosiah de Koeyer <dev@yosiahdekoeyer.dev>
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @Y0sh1dk, 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 addresses a critical bug in the FeatureFlag Custom Resource validation webhook. Previously, updates to FeatureFlag resources were validated against their old state, which allowed invalid configurations to be applied and led to unrecoverable resource states. The change ensures that all FeatureFlag updates are now properly validated against the new, intended state, thereby maintaining data integrity and preventing resource corruption. This fix is complemented by new end-to-end tests to ensure the validation behaves as expected.

Highlights

  • Fix Validation Logic: The FeatureFlag Custom Resource update validation webhook now correctly validates the newObj instead of the oldObj, preventing FeatureFlag resources from entering an unrecoverable bad state due to incorrect validation.
  • New E2E Tests: Dedicated end-to-end tests have been added to specifically cover the FeatureFlag update validation scenario, ensuring that invalid updates are rejected as expected and preventing future regressions.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize 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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Signed-off-by: Yosiah de Koeyer <dev@yosiahdekoeyer.dev>

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request correctly fixes a critical bug in the FeatureFlag update validation logic by ensuring the new object state is validated instead of the old one. The code changes are clean and the addition of end-to-end tests for the update scenario is a great improvement. My review focuses on refining the new test case to ensure it is accurate and maintainable.

Comment thread test/e2e/chainsaw/validate-featureflag-update/chainsaw-test.yaml Outdated
Comment thread test/e2e/chainsaw/validate-featureflag-update/chainsaw-test.yaml Outdated
@codecov

codecov Bot commented Dec 15, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.33%. Comparing base (499661e) to head (7d83779).
⚠️ Report is 75 commits behind head on main.

Files with missing lines Patch % Lines
internal/webhook/featureflag_webhook.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #790       +/-   ##
===========================================
- Coverage   86.51%   72.33%   -14.19%     
===========================================
  Files          19       30       +11     
  Lines        1587     1923      +336     
===========================================
+ Hits         1373     1391       +18     
- Misses        173      484      +311     
- Partials       41       48        +7     
Files with missing lines Coverage Δ
internal/webhook/featureflag_webhook.go 39.21% <0.00%> (ø)

... and 25 files with indirect coverage changes

Flag Coverage Δ
unit-tests 72.33% <0.00%> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Yosiah de Koeyer <dev@yosiahdekoeyer.dev>
@beeme1mr beeme1mr merged commit e36455e into open-feature:main Jan 5, 2026
17 of 19 checks passed
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.

2 participants