Repository navigation
Conversation
A secret key without the Feature flags: Read scope gets 401 from /flags/definitions on every poll, so the definition loader logged a warning every poll. Warn once for 401 and 403 with the scope and the enable_local_evaluation: false opt-out, and again only after definitions load. Definitions still clear, and 402 keeps its per-poll warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note 🤖 Claude Opus 5.5 responding on behalf of Michael Decisions made while building this fix:
|
posthog-elixir Compliance ReportDate: 2026-11-05T12:15:00.092207+00:00
|
| Test | Status | Duration |
|---|---|---|
| Format Validation.Event Has Required Fields | ✅ | 610ms |
| Format Validation.Event Has Uuid | ✅ | 610ms |
| Format Validation.Event Has Lib Properties | ✅ | 610ms |
| Format Validation.Distinct Id Is String | ✅ | 609ms |
| Format Validation.Token Is Present | ✅ | 610ms |
| Format Validation.Custom Properties Preserved | ✅ | 610ms |
| Format Validation.Event Has Timestamp | ✅ | 609ms |
| Format Validation.Non Utc Event Timestamp Is Converted To Utc | ❌ | 610ms |
| Retry Behavior.Retries On 503 | ✅ | 5615ms |
| Retry Behavior.Does Not Retry On 400 | ✅ | 2613ms |
| Retry Behavior.Does Not Retry On 401 | ✅ | 2613ms |
| Retry Behavior.Respects Retry After Header | ✅ | 5614ms |
| Retry Behavior.Implements Backoff | ✅ | 15624ms |
| Retry Behavior.Retries On 500 | ✅ | 5616ms |
| Retry Behavior.Retries On 502 | ✅ | 5616ms |
| Retry Behavior.Retries On 504 | ✅ | 5616ms |
| Retry Behavior.Max Retries Respected | ✅ | 15618ms |
| Deduplication.Generates Unique Uuids | ✅ | 622ms |
| Deduplication.Preserves Uuid On Retry | ✅ | 5614ms |
| Deduplication.Preserves Uuid And Timestamp On Retry | ✅ | 10615ms |
| Deduplication.Preserves Uuid And Timestamp On Batch Retry | ✅ | 5618ms |
| Deduplication.No Duplicate Events In Batch | ✅ | 616ms |
| Deduplication.Different Events Have Different Uuids | ✅ | 615ms |
| Compression.Sends Gzip When Enabled | ✅ | 610ms |
| Batch Format.Uses Proper Batch Structure | ✅ | 610ms |
| Batch Format.Flush With No Events Sends Nothing | ✅ | 607ms |
| Batch Format.Multiple Events Batched Together | ✅ | 615ms |
| Error Handling.Does Not Retry On 403 | ✅ | 2612ms |
| Error Handling.Does Not Retry On 413 | ✅ | 2613ms |
| Error Handling.Retries On 408 | ✅ | 5616ms |
Failures
format_validation.non_utc_event_timestamp_is_converted_to_utc
Event 0 field 'timestamp' instant '2026-11-05T12:13:16.023740Z' != expected '2025-01-02T03:04:05Z'
Feature_Flags Tests
View Details
| Test | Status | Duration |
|---|---|---|
| Request Payload.Request With Person Properties Device Id | ✅ | 9ms |
| Request Payload.Flags Request Uses V2 Query Param | ✅ | 7ms |
| Request Payload.Flags Request Hits Flags Path Not Decide | ✅ | 7ms |
| Request Payload.Flags Request Omits Authorization Header | ✅ | 7ms |
| Request Payload.Token In Flags Body Matches Init | ✅ | 6ms |
| Request Payload.Groups Round Trip | ✅ | 7ms |
| Request Payload.Groups Default To Empty Object | ❌ | 7ms |
| Request Payload.Disable Geoip False Propagates As Geoip Disable False | ✅ | 7ms |
| Request Payload.Disable Geoip Omitted Defaults To False | ❌ | 7ms |
| Request Payload.Flag Keys To Evaluate Contains Only Requested Key | ✅ | 7ms |
| Request Lifecycle.No Flags Request On Init Alone | ✅ | 4ms |
| Request Lifecycle.No Flags Request On Normal Capture | ✅ | 609ms |
| Request Lifecycle.Two Flag Calls Produce Two Remote Requests | ✅ | 11ms |
| Request Lifecycle.Mock Response Value Is Returned To Caller | ❌ | 7ms |
| Retry Behavior.Retries Flags On 502 | ❌ | 310ms |
| Retry Behavior.Retries Flags On 504 | ❌ | 311ms |
| Side Effect Events.Get Feature Flag Captures Feature Flag Called Event | ❌ | 611ms |
Failures
request_payload.groups_default_to_empty_object
Field 'groups' not found in /flags request body at path 'groups'. Available keys: ['distinct_id', 'api_key', 'flag_keys_to_evaluate']
request_payload.disable_geoip_omitted_defaults_to_false
Field 'geoip_disable' not found in /flags request body at path 'geoip_disable'. Available keys: ['distinct_id', 'api_key', 'flag_keys_to_evaluate']
request_lifecycle.mock_response_value_is_returned_to_caller
Last action result missing field 'value'. Keys: ['error', 'success']
retry_behavior.retries_flags_on_502
Last action result missing field 'value'. Keys: ['error', 'success']
retry_behavior.retries_flags_on_504
Last action result missing field 'value'. Keys: ['error', 'success']
side_effect_events.get_feature_flag_captures_feature_flag_called_event
Expected 1 events with name '$feature_flag_called', got 0
|
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
💡 Motivation and Context
When you configure a
secret_key, local evaluation is on by default andPostHog.FeatureFlags.DefinitionLoaderpolls/flags/definitionswith it. Transactional email asks for a Project Secret API Key with only thetransactional_email:writescope. The flags service answers that key with401 authentication_failed("Secret API token is invalid."), the same answer as a wrong key, because its key lookup only finds keys with a flag scope. A personal API key without the scope gets403 permission_denied.So an app that only sends email logged
definition refresh was rejected with HTTP 401on every poll, for as long as it ran, about feature flags it never uses.Merge Danger
Low, two-way door. Only the logging for 401 and 403 from
/flags/definitionschanges. Definitions still clear on 401 and 403, and polling, 402, 429, timeouts, provider paths and remote evaluation are unchanged.What changes
enable_local_evaluation: falseturns local evaluation off.posthog_skip_capture: truelike the other loader logs. Any successful refresh (a 200 install, a 304 or a cache install) re-arms the warning, so a key that breaks later warns again.This PR is independent of the email PR #236. That PR doesn't touch the definition loader or its tests, and a merge of both is clean.
💚 How did you test it?
test/posthog/feature_flags/definition_loader_test.exs: a start plus four refreshes answered with 401 or 403 log one warning (none matched before the fix, which logged the old message every time), and a 200 between rejections warns again. They failed before the fix and pass now.mix test: 869 passed, 18 excluded.mix format --check-formatted,mix credo --strict,mix compile --warnings-as-errorsandmix posthog.public_api --checkpass.PostHog.SupervisorwithPostHog.API.Mockanswering/flags/definitions, read throughcapture_log.PostHog.Supervisorwithsecret_keyandfeature_flags_poll_interval_ms: 1_000polled a local stub of/flags/definitionsthat sends the flags service's 401 and 403 bodies. Over 8 polls (three 401s, a 200, then 401s) it logged two warnings, one before and one after the load, and debug lines for the rest. Five 403s logged one warning.rust/feature-flags/src/api/auth.rsanderrors.rsin PostHog/posthog.📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Claude Code (Claude Opus 5.5) wrote the change test-first in a T3 Code thread, as a side fix from the transactional email work. GPT-6.1 Sol reviewed the diff before the push and found nothing that holds. The same fix is going to posthog-node, posthog-python and posthog-go.
Logger.warning, thenLogger.debugInvolvement: one cross-family review (GPT-6.1 Sol), no grilling rounds, live-run proof against a local stub of the flags service.
🤖 Generated with Claude Code