From 6843874bcf485cba53c82400b3199c564296976b Mon Sep 17 00:00:00 2001 From: Simon Schrottner Date: Thu, 12 Mar 2026 16:12:07 +0100 Subject: [PATCH 1/3] test(semver): add edge case scenarios for v-prefix, partial versions, and build metadata Adds @semver-edge-cases tagged scenarios covering: - v-prefix versions (v1.0.0) stripped transparently on both sides - Partial versions (1, 1.2) padded with .0 components - Build metadata ignored per SemVer 2.0.0 Rule 10 Addresses: https://github.com/open-feature/flagd/issues/1873 Signed-off-by: Simon Schrottner Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- flags/custom-ops.json | 42 +++++++++++++++++++++++++++++++++++++++ gherkin/targeting.feature | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/flags/custom-ops.json b/flags/custom-ops.json index 85f5f9a..84b1a94 100644 --- a/flags/custom-ops.json +++ b/flags/custom-ops.json @@ -299,6 +299,48 @@ } ] } + }, + "semver-v-prefix-flag": { + "state": "ENABLED", + "variants": { + "match": "match", + "no-match": "no-match" + }, + "defaultVariant": "no-match", + "targeting": { + "if": [ + {"sem_ver": [{"var": "version"}, "=", "v1.0.0"]}, + "match", "no-match" + ] + } + }, + "semver-partial-version-flag": { + "state": "ENABLED", + "variants": { + "match": "match", + "no-match": "no-match" + }, + "defaultVariant": "no-match", + "targeting": { + "if": [ + {"sem_ver": [{"var": "version"}, "^", "1"]}, + "match", "no-match" + ] + } + }, + "semver-build-metadata-flag": { + "state": "ENABLED", + "variants": { + "match": "match", + "no-match": "no-match" + }, + "defaultVariant": "no-match", + "targeting": { + "if": [ + {"sem_ver": [{"var": "version"}, "=", "1.0.0+build"]}, + "match", "no-match" + ] + } } } } diff --git a/gherkin/targeting.feature b/gherkin/targeting.feature index 5dd7ae2..3b5d0a6 100644 --- a/gherkin/targeting.feature +++ b/gherkin/targeting.feature @@ -240,6 +240,42 @@ Feature: Targeting rules | 3.1.0 | major | | 4.0.0 | none | + @semver @semver-edge-cases + Scenario Outline: sem_ver v-prefix handling + Given a String-flag with key "semver-v-prefix-flag" and a default value "fallback" + And a context containing a key "version", with type "String" and with value "" + When the flag was evaluated with details + Then the resolved details value should be "" + Examples: + | version | value | + | 1.0.0 | match | + | v1.0.0 | match | + | 2.0.0 | no-match | + + @semver @semver-edge-cases + Scenario Outline: sem_ver partial version handling + Given a String-flag with key "semver-partial-version-flag" and a default value "fallback" + And a context containing a key "version", with type "String" and with value "" + When the flag was evaluated with details + Then the resolved details value should be "" + Examples: + | version | value | + | 1.5.0 | match | + | 1.0.0 | match | + | 2.0.0 | no-match | + + @semver @semver-edge-cases + Scenario Outline: sem_ver build metadata ignored + Given a String-flag with key "semver-build-metadata-flag" and a default value "fallback" + And a context containing a key "version", with type "String" and with value "" + When the flag was evaluated with details + Then the resolved details value should be "" + Examples: + | version | value | + | 1.0.0 | match | + | 1.0.0+other | match | + | 2.0.0 | no-match | + Scenario Outline: Time-based operations Given a Integer-flag with key "timestamp-flag" and a default value "0" And a context containing a key "time", with type "Integer" and with value "