Skip to content

chore: update endpoint for flags local eval#509

Merged
patricio-posthog merged 2 commits intomainfrom
patricio/update-local-eval-endpoint-definitive
Apr 15, 2026
Merged

chore: update endpoint for flags local eval#509
patricio-posthog merged 2 commits intomainfrom
patricio/update-local-eval-endpoint-definitive

Conversation

@patricio-posthog
Copy link
Copy Markdown
Contributor

💡 Motivation and Context

The Rust feature flags definitions fleet now serves 100% of /api/feature_flag/local_evaluation traffic in all environments (dev, prod-us, prod-eu) via Contour weighted routing. We saw zero errors after ramping 10% → 50% → 100% over the past week.

This PR switches the SDK's default polling URL from the legacy Django path (/api/feature_flag/local_evaluation/) to the Rust endpoint's native path (/flags/definitions). This also removes the intermediate POSTHOG_LOCAL_EVALUATION_ENDPOINT env var override and fallback logic that were added as temporary migration scaffolding.

The old /api/feature_flag/local_evaluation path remains registered as a route alias on the Rust service, so older SDK versions continue to work.

💚 How did you test it?

  • Existing tests pass (the removed TestLocalEvalEndpointConfig class tested the env var/fallback machinery that no longer exists)
  • The /flags/definitions endpoint has been serving production traffic since 2026-04-09 (PostHog internal SDK) and 100% of external traffic since 2026-04-15

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran sampo add to generate a changeset file
  • Added the release label to the PR

@patricio-posthog patricio-posthog requested a review from a team as a code owner April 15, 2026 15:10
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 15, 2026

Prompt To Fix All With AI
This is a comment left during a code review.
Path: posthog/test/test_feature_flags.py
Line: 3782

Comment:
**No test for new `/flags/definitions` URL**

`TestLocalEvalEndpointConfig` was the only test asserting what URL `_fetch_feature_flags_from_api` passes to `get()`. Now that it is removed there is nothing to prevent a silent regression if the hardcoded path is accidentally changed. A minimal parameterised replacement (even a single case) that checks `patch_get.call_args[0][1].startswith("/flags/definitions?")` would close this gap while keeping the test suite honest about the URL the SDK actually calls.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "chore: update endpoint for flags local e..." | Re-trigger Greptile

Comment thread posthog/test/test_feature_flags.py
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 15, 2026

posthog-python Compliance Report

Date: 2026-04-15 15:16:34 UTC
Duration: 159977ms

⚠️ Some Tests Failed

29/30 tests passed, 1 failed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 516ms
Format Validation.Event Has Uuid 1506ms
Format Validation.Event Has Lib Properties 1506ms
Format Validation.Distinct Id Is String 1507ms
Format Validation.Token Is Present 1505ms
Format Validation.Custom Properties Preserved 1505ms
Format Validation.Event Has Timestamp 1505ms
Retry Behavior.Retries On 503 9517ms
Retry Behavior.Does Not Retry On 400 3506ms
Retry Behavior.Does Not Retry On 401 3508ms
Retry Behavior.Respects Retry After Header 9513ms
Retry Behavior.Implements Backoff 23519ms
Retry Behavior.Retries On 500 7509ms
Retry Behavior.Retries On 502 7509ms
Retry Behavior.Retries On 504 7505ms
Retry Behavior.Max Retries Respected 23521ms
Deduplication.Generates Unique Uuids 1508ms
Deduplication.Preserves Uuid On Retry 7510ms
Deduplication.Preserves Uuid And Timestamp On Retry 14525ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7507ms
Deduplication.No Duplicate Events In Batch 1502ms
Deduplication.Different Events Have Different Uuids 1508ms
Compression.Sends Gzip When Enabled 1506ms
Batch Format.Uses Proper Batch Structure 1507ms
Batch Format.Flush With No Events Sends Nothing 1004ms
Batch Format.Multiple Events Batched Together 1504ms
Error Handling.Does Not Retry On 403 3509ms
Error Handling.Does Not Retry On 413 3507ms
Error Handling.Retries On 408 7509ms

Feature_Flags Tests

⚠️ 0/1 tests passed, 1 failed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 506ms

Failures

request_payload.request_with_person_properties_device_id

404, message='NOT FOUND', url='http://sdk-adapter:8080/get_feature_flag'

@patricio-posthog patricio-posthog merged commit f5a95b4 into main Apr 15, 2026
26 checks passed
@patricio-posthog patricio-posthog deleted the patricio/update-local-eval-endpoint-definitive branch April 15, 2026 15:35
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