Skip to content

feat: add strict validation option to reject invalid flag configs#1939

Open
buildingisfun23 wants to merge 3 commits into
open-feature:mainfrom
buildingisfun23:feat/1487-reject-invalid-flags
Open

feat: add strict validation option to reject invalid flag configs#1939
buildingisfun23 wants to merge 3 commits into
open-feature:mainfrom
buildingisfun23:feat/1487-reject-invalid-flags

Conversation

@buildingisfun23
Copy link
Copy Markdown

Summary

  • Adds WithStrictValidation() option to the JSON evaluator
  • When enabled, flag configurations that fail schema validation are rejected with an error instead of accepted with a warning
  • The flag store preserves its previous state when validation fails in strict mode
  • Backward compatible: default behavior (accept with warning) is unchanged
  • Includes 4 new tests covering strict/non-strict modes and state preservation

Fixes #1487

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 11, 2026

Deploy Preview for polite-licorice-3db33c ready!

Name Link
🔨 Latest commit 0858427
🔍 Latest deploy log https://app.netlify.com/projects/polite-licorice-3db33c/deploys/69f3e445fe7e4900087c5543
😎 Deploy Preview https://deploy-preview-1939--polite-licorice-3db33c.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

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 introduces a strict schema validation option for the JSON evaluator. It adds a WithStrictValidation option that, when enabled, causes flag configurations failing schema validation to return an error instead of just logging a warning. The changes include updates to the JSON struct, the validation logic, and comprehensive unit tests to verify the new behavior and ensure backward compatibility. Feedback suggests using the %w verb for error wrapping in the new error return path to follow Go best practices.

Comment thread core/pkg/evaluator/json.go Outdated
@buildingisfun23 buildingisfun23 force-pushed the feat/1487-reject-invalid-flags branch from 2791d98 to 5fe79e8 Compare April 13, 2026 01:04
@buildingisfun23 buildingisfun23 marked this pull request as ready for review April 14, 2026 00:46
@buildingisfun23 buildingisfun23 requested review from a team as code owners April 14, 2026 00:46
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 14, 2026
@toddbaert
Copy link
Copy Markdown
Member

@buildingisfun23 - I'm not opposed - I wonder if we should connect this directly to a flagd startup arg as well? WDYT?

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 19, 2026
@buildingisfun23
Copy link
Copy Markdown
Author

Good call @toddbaert! I've added --strict-validation as a flagd startup argument (also available as FLAGD_STRICT_VALIDATION env var via viper). It wires through the existing WithStrictValidation() evaluator option so operators can enable strict schema validation at startup without any code changes.

@buildingisfun23 buildingisfun23 force-pushed the feat/1487-reject-invalid-flags branch from a5d2bb6 to 3bf7ff7 Compare April 19, 2026 02:27
@toddbaert
Copy link
Copy Markdown
Member

toddbaert commented Apr 30, 2026

Hey @buildingisfun23 - thanks again. I've been thinking about this and I think it made sense to make one more change...

I made--strict-validation fail-fast: invalid initial configs exit the process, and readiness now requires every configured source to have produced a valid config at least once. Help text got a cascading-failure warning so SREs know what they're opting into.

This is opt in, and it matches similar behavior in things like envoy/nginx. See changes.

WDYT? Does this make sense? Should we divide it into 2 options? I kept thinking it would be weird to have no flags if an initial sync fails, and it led be down this path.

buildingisfun23 and others added 3 commits April 30, 2026 19:22
…en-feature#1487)

Add WithStrictValidation() option for the JSON evaluator that causes
flag configurations failing schema validation to be rejected with an
error instead of accepted with a warning. When enabled, the flag store
retains its previous state on validation failure.

This is an opt-in option to avoid breaking existing behavior.

Signed-off-by: buildingisfun23 <buildingisfun23@users.noreply.github.com>
Wire the existing WithStrictValidation() evaluator option through to a
new --strict-validation CLI flag (and FLAGD_STRICT_VALIDATION env var)
so operators can enable strict schema validation at startup without
needing to configure it programmatically.

Signed-off-by: buildingisfun23 <buildingisfun23@users.noreply.github.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
@toddbaert toddbaert force-pushed the feat/1487-reject-invalid-flags branch from f03059e to 0858427 Compare April 30, 2026 23:22
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] provider option to reject flag set with invalid rules

2 participants