chore(feature_flags): warn on empty schema and empty rules - #8430
Open
dreamorosi wants to merge 1 commit into
Open
chore(feature_flags): warn on empty schema and empty rules#8430dreamorosi wants to merge 1 commit into
dreamorosi wants to merge 1 commit into
Conversation
SchemaValidator accepted an empty top-level document and any feature whose 'rules' key was present but falsy (including a list) without any signal. These are harmless for evaluation, but they usually indicate an authoring mistake such as a typo'd envelope path. Emit a warning log for an empty schema, for a feature whose 'rules' is present but empty, and a more specific warning when the empty value is not a dictionary. Nothing is raised, so existing documents keep validating. Omitting 'rules' entirely stays silent since that is the documented way to declare a static flag. Pass the real feature name into RulesValidator. It previously derived the name from the feature's first key (usually 'default'), so error and warning messages named the wrong thing. Closes #8427
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8430 +/- ##
========================================
Coverage 96.65% 96.65%
========================================
Files 296 296
Lines 14767 14774 +7
Branches 1246 1249 +3
========================================
+ Hits 14273 14280 +7
Misses 359 359
Partials 135 135 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dreamorosi
marked this pull request as ready for review
September 3, 2026 16:38
dreamorosi
requested review from
leandrodamascena and
svozza
and removed request for
svozza
September 3, 2026 16:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue number: closes #8427
Summary
Changes
SchemaValidatornow emits awarninglog for documents that are valid but almost certainly not what the author meant. Nothing is raised, so every document that validated before still validates.Three cases are covered:
{}). Typically the result of an envelope query that matched nothing, e.g. a typo'd feature group name.ruleskey is present but empty ({}orNone).ruleskey is present, empty, and not a dictionary ([],""). This gets a more specific message because the same value, once populated, would be rejected withSchemaValidationError; the empty form only slipped through becauseif not self.rulesshort-circuits first.Omitting
rulesentirely stays silent, since that is the documented way to declare a static flag.While wiring the warning I found that
RulesValidatorderivedfeature_namefromnext(iter(self.feature)), i.e. the feature's first key ("default"in practice), not its name.FeaturesValidatornow passes the real name in through a new optionalfeature_nameargument, so the new warnings and the existingFeature rules must be a dictionary, feature=...error name the right feature. The old fallback is kept so direct construction without the argument keeps working.Tests pin each warning's level and message, and pin the two silent paths (well-formed document,
rulesomitted) so the warnings do not become noisy.The TypeScript port (aws-powertools/powertools-lambda-typescript#5614) warns on the same cases and throws only where Python throws, so documents stay portable between runtimes.
User experience
No behaviour change for
evaluateorget_enabled_features. The only difference is in logs:{}WARNING Feature flags schema is empty, no features to validate{"f": {"default": false, "rules": {}}}WARNING Feature has 'rules' but it is empty, feature=f{"f": {"default": false, "rules": []}}WARNING Feature 'rules' should be a dictionary but is an empty list, feature=f{"f": {"default": false}}{"f": {"default": false, "rules": "4"}}feature=finstead offeature=defaultBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.