Skip to content

fix: retain response errors in poller flag events - #445

Merged
marandaneto merged 1 commit into
mainfrom
fix/spec211-failed-flags
Nov 13, 2026
Merged

marandaneto merged 1 commit into
mainfrom
fix/spec211-failed-flags

Conversation

@marandaneto

Copy link
Copy Markdown
Member

💡 Motivation and Context

When a direct flag read falls back through the local poller, the emitted event loses errors_while_computing_flags even though the remote response reports it. A failed flag still reports evaluation_failed, so the event hides the separate response-wide failure.

This implements the affected telemetry requirement from PostHog/sdk-specs#211. The poller now carries the response-wide error bit into the existing event diagnostics. Failed reads keep their nil result, error, and nil event-response sentinel. Healthy false results, local successes, event controls, dedupe, and value/payload handling are unchanged. No public API is added.

Includes an existing Changesets patch intent for posthog-go.

💚 How did you test it?

  • go test -race -count=1 -timeout=5m ./...: passed across all root-module packages.
  • go vet ./..., make api-diff, scoped gofmt -l, and git diff --check: passed.
  • Twelve regression subtests cover global-error true/false/absent, missing and inconclusive local definitions, failed false and variant placeholders, exact diagnostics, nil response, dedupe, suppression, and healthy false siblings. Earlier pre-fix execution failed all four global-true cases because the response-wide error was missing.
  • Signed committed branch passed the required isolated autoreview with no actionable findings.

Validation used Go 1.26.4 on macOS arm64. Separate nested modules and the full supported toolchain/platform matrix were not run. An earlier independent review saw one timeout waiting for an event in an unchanged healthy no-poller test. Three isolated repetitions, its full-suite retry, and this publication run passed. This is not a claim of full shared-harness conformance.

📝 Checklist

  • All commits are signed (see Commit signing)
  • 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 pnpm changeset to generate a changeset file

The patch changeset is already included. The generator was not rerun during publication.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Pi agents used local shell, Git, Go tooling, and GitHub CLI to implement, validate, independently review, and publish this scoped fix. The committed branch also passed the autoreview helper using its configured Claude Code model. No externally accessible agent session link is available.

The fix propagates one internal diagnostic field through the existing evaluation path rather than changing value semantics or adding an API. Human review is required before merge.

@marandaneto marandaneto self-assigned this Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

posthog-go Compliance Report

Date: 2026-11-12 10:33:56 UTC
Duration: 169219ms

✅ All Tests Passed!

111/111 tests passed


Capture_V1 Tests

✅ 94/94 tests passed

View Details
Test Status Duration
Endpoint And Method.Targets V1 Endpoint ✅ 18ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 7ms
Required Headers.Has Authorization Bearer Header ✅ 6ms
Required Headers.Has Content Type Json ✅ 6ms
Required Headers.Has Posthog Sdk Info Format ✅ 7ms
Required Headers.Has Posthog Attempt Header ✅ 7ms
Required Headers.Has Posthog Request Id ✅ 6ms
Required Headers.Has Posthog Request Timestamp ✅ 6ms
Required Headers.Has User Agent ✅ 6ms
Body Format.Body Has Created At And Batch ✅ 7ms
Body Format.No Api Key In Body ✅ 6ms
Body Format.No Sent At In Body ✅ 6ms
Event Format.Event Has Required Root Fields ✅ 7ms
Event Format.Event Uuid Is Valid ✅ 6ms
Event Format.Event Timestamp Is Rfc3339 ✅ 6ms
Event Format.Distinct Id Is String ✅ 6ms
Event Format.Distinct Id At Root Not Properties ✅ 16ms
Event Format.Custom Properties Preserved ✅ 7ms
Event Format.Set Properties Preserved ✅ 6ms
Event Format.Set Once Properties Preserved ✅ 6ms
Event Format.Groups Properties Preserved ✅ 6ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 6ms
Event Format.Event Has Required Root Fields Batch ✅ 9ms
Event Format.Event Uuid Is Valid Batch ✅ 9ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 19ms
Event Format.Distinct Id Is String Batch ✅ 9ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 9ms
Event Format.Custom Properties Preserved Batch ✅ 9ms
Event Format.Set Properties Preserved Batch ✅ 9ms
Event Format.Set Once Properties Preserved Batch ✅ 8ms
Event Format.Groups Properties Preserved Batch ✅ 8ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 9ms
Batch Behavior.Multiple Events In Single Batch ✅ 30ms
Batch Behavior.Batch Envelope Smoke ✅ 10ms
Batch Behavior.Flush With No Events Sends Nothing ✅ 4ms
Batch Behavior.Flush At Triggers Batch ✅ 1007ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 7ms
Deduplication.Generates Unique Uuids ✅ 16ms
Deduplication.Different Events Same Content Different Uuids ✅ 8ms
Deduplication.Preserves Uuid On Retry ✅ 5133ms
Deduplication.Preserves Timestamp On Retry ✅ 5133ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5134ms
Deduplication.No Duplicate Events In Batch ✅ 33ms
Header Behavior On Retry.Attempt Header Starts At One ✅ 6ms
Header Behavior On Retry.Attempt Header Increments On Retry ✅ 10139ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 5137ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 2014ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 5135ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 7ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 29ms
Response Format Validation.Success No Retry After When All Ok ✅ 27ms
Response Format Validation.Success Retry After Present When Retry Events ✅ 130ms
Response Format Validation.Success No Retry After When Drop Only ✅ 28ms
Response Format Validation.Response Echoes Request Id ✅ 6ms
Retry Behavior.Retries On 408 ✅ 5135ms
Retry Behavior.Retries On 500 ✅ 5134ms
Retry Behavior.Retries On 503 ✅ 5136ms
Retry Behavior.Retries On 504 ✅ 5133ms
Retry Behavior.Retryable Errors Have Retry After ✅ 2133ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 8139ms
Retry Behavior.Does Not Retry On 400 ✅ 2132ms
Retry Behavior.Does Not Retry On 401 ✅ 2132ms
Retry Behavior.Does Not Retry On 402 ✅ 2134ms
Retry Behavior.Does Not Retry On 413 ✅ 2133ms
Retry Behavior.Does Not Retry On 415 ✅ 2133ms
Retry Behavior.Non Retryable Errors Have No Retry After ✅ 2131ms
Retry Behavior.Implements Backoff ✅ 15134ms
Retry Behavior.Max Retries Respected ✅ 15138ms
Partial Batch Handling.Handles 200 Full Success ✅ 2010ms
Partial Batch Handling.Handles 200 With All Ok ✅ 3033ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 3030ms
Partial Batch Handling.Does Not Retry Limited Events ✅ 3031ms
Partial Batch Handling.Prunes Ok Events On Partial Retry ✅ 5134ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry ✅ 5134ms
Partial Batch Handling.Retries Only Retry Events From Partial ✅ 5137ms
Partial Batch Handling.Partial Retry Preserves Uuids ✅ 5135ms
Partial Batch Handling.Partial Retry Attempt Header Increments ✅ 5133ms
Partial Batch Handling.Partial Retry Request Id Preserved ✅ 5133ms
Partial Batch Handling.Respects Retry After On Partial ✅ 5136ms
Partial Batch Handling.Unknown Result Treated As Terminal ✅ 3030ms
Partial Batch Handling.Mixed Ok Drop Limited No Retry ✅ 3033ms
Compression.Sends Gzip Content Encoding ✅ 16ms
Compression.No Content Encoding When Disabled ✅ 6ms
Compression.Compressed Body Is Decompressible ✅ 16ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 2131ms
Event Options.Cookieless Mode Override ✅ 18ms
Event Options.Disable Skew Correction Override ✅ 6ms
Event Options.Process Person Profile Override ✅ 6ms
Event Options.Product Tour Id Override ✅ 7ms
Event Options.Unset Options Omitted ✅ 5ms
Event Options.Options Override In Batch ✅ 8ms
Geoip And Historical Migration.Geoip Disable Injected Into Properties ✅ 6ms
Geoip And Historical Migration.Historical Migration Set In Body ✅ 6ms
Geoip And Historical Migration.Historical Migration Absent By Default ✅ 6ms

Feature_Flags Tests

✅ 17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 16ms
Request Payload.Flags Request Uses V2 Query Param ✅ 16ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 15ms
Request Payload.Flags Request Omits Authorization Header ✅ 16ms
Request Payload.Token In Flags Body Matches Init ✅ 16ms
Request Payload.Groups Round Trip ✅ 16ms
Request Payload.Groups Default To Empty Object ✅ 16ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 15ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 16ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 16ms
Request Lifecycle.No Flags Request On Init Alone ✅ 3ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 6ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 29ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 16ms
Retry Behavior.Retries Flags On 502 ✅ 17ms
Retry Behavior.Retries Flags On 504 ✅ 17ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 17ms

@marandaneto
marandaneto marked this pull request as ready for review November 12, 2026 12:13
@marandaneto
marandaneto requested a review from a team as a code owner November 12, 2026 12:13
@veria-ai

veria-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@marandaneto
marandaneto merged commit 63617ab into main Nov 13, 2026
39 checks passed
@marandaneto
marandaneto deleted the fix/spec211-failed-flags branch November 13, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants