Skip to content

feat: Add feature flag support to option schema#91

Open
markstory wants to merge 13 commits intomainfrom
feat-add-feature-schema
Open

feat: Add feature flag support to option schema#91
markstory wants to merge 13 commits intomainfrom
feat-add-feature-schema

Conversation

@markstory
Copy link
Member

Add feature flag support to option schema. The option schema that applications generate will reference a definition that is spliced in when the schema file is processed by sentry-options.

This is the first step to having feature flags stored as structured data in the options file.

Part of the alternative approach to #84

First pass with claude.
Add feature flag support to option schema. The option schema that
applications generate will reference a definition that is spliced in
when the schema file is processed by sentry-options.

This is the first step to having feature flags stored as structured
data in the options file.

Part of the alternative approach to #84
The namespace schema can include non-feature values.
Comment on lines +1323 to +1325
"features.organizations:fury-mode": {
"$ref": "#/definitions/Feature"
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we compile options schema for an application, each feature flag will be included with a $ref. This lets us validate feature flag names, and the flag values.

Copy link
Member

@kenzoengineer kenzoengineer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, small call-out: old flagpole uses feature.* but this system expected features.*

@markstory
Copy link
Member Author

lgtm, small call-out: old flagpole uses feature.* but this system expected features.*

I'll get those prefixes aligned.

Having the prefixes aligned makes working with existing data much
simpler.
"properties": {
"$ref": {
"type": "string",
"pattern": "#/definitions/Feature"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unanchored $ref pattern allows invalid reference values

Low Severity

The pattern for the $ref property is "#/definitions/Feature" without ^ and $ anchors. JSON Schema's pattern keyword does substring matching, so values like "#/definitions/FeatureXYZ" or "foo#/definitions/Feature" would pass meta-schema validation but fail at runtime when the $ref can't be resolved. The version pattern on line 6 correctly uses "^[0-9]+\\.[0-9]+$" — the same anchoring is needed here.

Fix in Cursor Fix in Web

}
}

// Inject additionalProperties: false to reject unknown options
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had to do this too, not the most clean but necessary for being more strict

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we have another copy of this logic higher up in the function after I merged main in. I'll remove the redundant block.

]
}
},
"additionalProperties": false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will removal of this be a problem? i don't think it will but just double checking

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be ok, as all properties should either be feature.* or !feature.*. I'll add it back just to be safe.

@kenzoengineer
Copy link
Member

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

While all properties should be `feature` or ! `feature` this doesn't
cause test failures.
I don't think we get any value from having feature names in both the
feature config and the option key. Instead we could just use the option
name as the feature name.
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.

3 participants