feat: add semver targeting support to local flag evaluation#447
Open
feat: add semver targeting support to local flag evaluation#447
Conversation
Implement 9 semver comparison operators (semver_eq, semver_neq, semver_gt, semver_gte, semver_lt, semver_lte, semver_tilde, semver_caret, semver_wildcard) for feature flag local evaluation. Uses regex-based parsing that matches the server-side sortableSemver behavior to handle v-prefix, whitespace, pre-release suffixes, and non-standard version formats. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Contributor
posthog-python Compliance ReportDate: 2026-02-27 01:55:47 UTC ✅ All Tests Passed!29/29 tests passed Capture Tests✅ 29/29 tests passed View Details
|
Add input length limit before regex search to prevent polynomial backtracking on adversarial input (CodeQL py/polynomial-redos).
Replace SEMVER_EXTRACT_RE regex with simple string splitting to eliminate nested quantifiers that CodeQL flagged as polynomial-redos.
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.
Summary
semver_eq,semver_neq,semver_gt,semver_gte,semver_lt,semver_lte,semver_tilde,semver_caret,semver_wildcard) for local feature flag evaluationuser_blast_radiusposthog#44596Why not use a semver library?
Libraries like
packagingandsemverexist but aren't runtime dependencies of this SDK. The current runtime deps are intentionally minimal (requests,six,python-dateutil,backoff,distro,typing-extensions), and adding a dependency for ~20 lines of string splitting isn't worth the install footprint cost for SDK consumers. The Rust feature-flags service uses its ecosystem'ssemvercrate, but Rust deps don't have the same user-facing cost as Python deps.Test plan
^0.x.ybehavior per semver spec