Skip to content

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

Open
buildingisfun23 wants to merge 2 commits intoopen-feature:mainfrom
buildingisfun23:feat/1487-reject-invalid-flags
Open

feat: add strict validation option to reject invalid flag configs#1939
buildingisfun23 wants to merge 2 commits intoopen-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 3bf7ff7
🔍 Latest deploy log https://app.netlify.com/projects/polite-licorice-3db33c/deploys/69e43d8b3a57af0007054439
😎 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.

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.

…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>
@buildingisfun23 buildingisfun23 force-pushed the feat/1487-reject-invalid-flags branch from a5d2bb6 to 3bf7ff7 Compare April 19, 2026 02:27
@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