Skip to content

refactor: add PROPERTY_OPERATORS constant for match_property#448

Merged
dmarticus merged 9 commits intomasterfrom
dmarticus/operator-constants
Mar 2, 2026
Merged

refactor: add PROPERTY_OPERATORS constant for match_property#448
dmarticus merged 9 commits intomasterfrom
dmarticus/operator-constants

Conversation

@dmarticus
Copy link
Contributor

@dmarticus dmarticus commented Feb 27, 2026

Summary

  • Extract all 21 operator strings into a PROPERTY_OPERATORS tuple as a single source of truth for what match_property supports
  • Add early validation at the top of match_property instead of relying on a fallthrough at the end
  • No logic changes - the if/elif dispatch chains are untouched

Stacked on #447 (semver targeting).

Test plan

  • All 115 existing tests pass unchanged
  • test_unknown_operator still validates unknown operators are rejected

dmarticus and others added 5 commits February 26, 2026 17:38
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>
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.
Extract all operator strings into a single source-of-truth tuple and
validate against it early in match_property, replacing the fallthrough
at the end of the function.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2026

posthog-python Compliance Report

Date: 2026-03-02 21:12:24 UTC
Duration: 159368ms

✅ All Tests Passed!

29/29 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 517ms
Format Validation.Event Has Uuid 1507ms
Format Validation.Event Has Lib Properties 1507ms
Format Validation.Distinct Id Is String 1507ms
Format Validation.Token Is Present 1507ms
Format Validation.Custom Properties Preserved 1507ms
Format Validation.Event Has Timestamp 1507ms
Retry Behavior.Retries On 503 9514ms
Retry Behavior.Does Not Retry On 400 3511ms
Retry Behavior.Does Not Retry On 401 3507ms
Retry Behavior.Respects Retry After Header 9514ms
Retry Behavior.Implements Backoff 23528ms
Retry Behavior.Retries On 500 7501ms
Retry Behavior.Retries On 502 7516ms
Retry Behavior.Retries On 504 7511ms
Retry Behavior.Max Retries Respected 23529ms
Deduplication.Generates Unique Uuids 1496ms
Deduplication.Preserves Uuid On Retry 7513ms
Deduplication.Preserves Uuid And Timestamp On Retry 14522ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7505ms
Deduplication.No Duplicate Events In Batch 1508ms
Deduplication.Different Events Have Different Uuids 1506ms
Compression.Sends Gzip When Enabled 1508ms
Batch Format.Uses Proper Batch Structure 1506ms
Batch Format.Flush With No Events Sends Nothing 1005ms
Batch Format.Multiple Events Batched Together 1505ms
Error Handling.Does Not Retry On 403 3509ms
Error Handling.Does Not Retry On 413 3506ms
Error Handling.Retries On 408 7511ms

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Break the flat tuple into category-specific tuples (EQUALITY_OPERATORS,
STRING_OPERATORS, etc.) that compose into PROPERTY_OPERATORS via
concatenation. The semver dispatch code now references
SEMVER_OPERATORS and SEMVER_COMPARISON_OPERATORS instead of
repeating the full operator lists inline.
Resolve conflicts by keeping extracted operator constants
(SEMVER_OPERATORS, SEMVER_COMPARISON_OPERATORS) over the inline
tuples that landed from the semver targeting PR.
@dmarticus dmarticus enabled auto-merge (squash) March 2, 2026 21:09
@dmarticus dmarticus merged commit 8d83315 into master Mar 2, 2026
21 checks passed
@dmarticus dmarticus deleted the dmarticus/operator-constants branch March 2, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants