Repository navigation
Implement starts_with, ends_with, and sem_ver custom operators - #5
Merged
Merged
Conversation
Co-authored-by: aepfli <9987394+aepfli@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement custom operators for flagd compatibility
Implement starts_with, ends_with, and sem_ver custom operators
Dec 1, 2025
aepfli
marked this pull request as ready for review
December 1, 2025 21:26
aepfli
approved these changes
Dec 1, 2025
aepfli
added a commit
that referenced
this pull request
Mar 14, 2026
) * feat(java): implement flagd-api Evaluator interface in FlagEvaluator Closes #2 - Add flagd-api 0.1.0 dependency to pom.xml - Make FlagEvaluator implement dev.openfeature.contrib.tools.flagd.api.Evaluator - Bridge setFlags/setFlagsAndGetChangedKeys to updateState (throws FlagStoreException on failure) - Bridge per-type resolve methods to evaluateFlag with EvaluationResult→ProviderEvaluation conversion - Add mapErrorCode helper for error code translation - Add EvaluatorInterfaceTest covering all interface methods Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com> * refactor(java): extract updateStateAndHandleErrors helper Eliminate duplicated error handling logic between setFlags and setFlagsAndGetChangedKeys by extracting a private helper method. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com> --------- Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Implements remaining flagd custom operators to achieve full compatibility with the flagd specification.
New Operators
starts_with/ends_with- Case-sensitive string prefix/suffix matchingsem_ver- Semantic version comparison per semver.org with operators:=,!=,<,<=,>,>=,^(caret),~(tilde)Usage
{"starts_with": [{"var": "email"}, "admin@"]} {"ends_with": [{"var": "filename"}, ".pdf"]} {"sem_ver": [{"var": "app.version"}, ">=", "2.0.0"]} {"sem_ver": [{"var": "version"}, "^", "1.2.3"]}Implementation
SemVerstruct with parser handling pre-release tags, build metadata, missing parts, andvprefixes^1.2.3matches>=1.2.3 <2.0.0(special handling for 0.x versions per npm conventions)~1.2.3matches>=1.2.3 <1.3.0{"var": "path"}referencesOriginal prompt
This section details on the original issue you should resolve
<issue_title>Implement all flagd custom operators for feature flag evaluation</issue_title>
<issue_description>
Labels
enhancement,feature,operators,flagd-compatibilityDescription
This issue tracks the implementation of all custom operators from the flagd specification to achieve full compatibility with flagd's evaluation engine.
Currently,
flagd-evaluatoronly implements thefractionaloperator. To provide feature parity with flagd, we need to implement all remaining custom operators.Background
flagd extends standard JSONLogic with custom operators specifically designed for feature flag evaluation. These operators enable advanced targeting rules including:
Custom Operators to Implement
1. ✅
fractional(Already Implemented)Status: Complete
Purpose: Deterministic percentage-based bucket assignment using consistent hashing
Syntax:
{ "fractional": [ { "var": "targetingKey" }, ["bucketA", 50, "bucketB", 30, "bucketC", 20] ] }Behavior:
Example:
2. ⬜
sem_ver(Semantic Version Comparison)Status: Not implemented
Purpose: Compare semantic versions according to semver.org specification
Syntax:
{ "sem_ver": [ { "var": "app.version" }, "operator", "target_version" ] }Supported Operators:
"="- Equal to"!="- Not equal to"<"- Less than"<="- Less than or equal to">"- Greater than">="- Greater than or equal to"^"- Caret range (compatible with - allows patch and minor updates)"~"- Tilde range (allows patch updates only)Examples:
Edge Cases:
Implementation Notes:
3. ⬜
starts_with(String Prefix Match)Status: Not implemented
Purpose: Check if a string starts with a specific prefix
Syntax:
{ "starts_with": [ { "var": "string_value" }, "prefix" ] }Examples:
Edge Cases:
4. ⬜
ends_with(String Suffix Match)Status: Not implemented
Purpose: Check if a string ends with a specific suffix
Syntax:
{ "ends_with": [ { "var": "string_value" }, "suffix" ] }Examples:
Edge Cases:
Implementation Requirements
General Requirements
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.