Repository navigation
fix(flags): answer get_remote_config_payload with the payload PostHog holds - #424
posthog[bot] wants to merge 1 commit into
Conversation
… holds Give the remote config read its own request path instead of sharing the flags endpoints' `_request`, whose status merging, retries and re-raising are shaped for a different contract. - Decode the body as JSON and, when that yields a string, parse it once more; a string that is not JSON comes back unchanged. - Stop merging `:status` into a decoded payload object. - Return nil, with no logged failure, for the status 200 empty body PostHog answers for a flag with no payload. - Return nil and log for a non-2xx status or a request that does not complete, rather than decoding an error body or raising at the caller. - Send no request when the project token or the secret key is missing, empty or only whitespace, token checked first. Generated-By: PostHog Desktop Task-Id: 67e18c57-5e3c-48ec-af06-eed0ddeafe81
posthog-ruby-sync Compliance ReportDate: 2026-12-05T07:09:02.331969+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
posthog-ruby-async Compliance ReportDate: 2026-12-05T07:09:06.586628+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
SDK performance: posthog-rubyBenchmarks completed. No changes flagged for review. Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate. View all results
Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals. Each shard uses its own runner; compare Before PR against With PR within a row, not across shards. Compared 102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in |
💡 Motivation and Context
get_remote_config_payloadshares the flags endpoints' internal request helper, whose shape doesn't match this capability's contract. Today it can hand callers a payload that isn't the payload: the JSON text of an object instead of the object, an added:statuskey, or a fabricated{ error: 'Invalid JSON response', body: '', status: 200 }hash for the empty 200 body PostHog returns for a flag with no payload. A connection failure re-raises at the caller.Contract: Get Remote Config Payload in
sdk-specs. The compliance matrix scores this row 🟡 Partial for posthog-ruby, noting that of the four implementations of this capability scored so far this is the weakest: no secret key check,:statusmerged into the payload, no second JSON parse, an error hash standing in for "no payload", and a re-raise on request failure. (Key encoding, also listed there, already landed in 3.43.1.)Changes
The remote config read gets its own small request path rather than sharing
_request, whose status merging, retries and re-raising are shaped for the flags endpoints."{\"foo\":1}"gives{ foo: 1 }and"hello world"giveshello world.:statusin the payload. A decoded object is the payload as PostHog holds it.niland logs nothing.niland a logged error instead of a decoded error body or a raised exception. Each call still sends exactly one request and is not retried.Backwards compatibility
Backwards-compatible, and additive in effect: every change replaces a wrong or fabricated answer with the payload the method is documented to return. No caller can depend on a
:statuskey injected into a flag payload, on an error hash standing in for "no payload", or on an exception escaping a read. No public signature changes (public_api_snapshot.txtis unchanged); the@returndoc is corrected. Existing behavior for a successful object payload and for a plaintext string payload is unchanged.💚 How did you test it?
Added specs in
spec/posthog/flags_spec.rbcovering each spec scenario: the decoding table ({}, an object, a JSON string holding an object/array/number, a nested string left alone, a string that is not JSON,""), no:statusin a decoded object, the empty 200 body logging nothing, 401/404/500, a connection failure with no raise and no retry, a later call succeeding after a failure, and blank/missing secret key and whitespace-only project token sending no request.Not run locally: no Ruby toolchain was available in this environment, so
bundle exec rspecandbundle exec rubocopwere not executed. Please let CI confirm before review.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset fileFollow-up
sdk_compliance_adapterhas no remote config operation, so this capability isn't exercised by the shared harness yet.nilsecret key as missing when loading flag definitions; this PR doesn't change that path.🤖 Agent context
Autonomy: Fully autonomous
Opened by a scheduled PostHog agent run that reads the
sdk-specscompliance matrices and implements one backwards-compatible gap per run. This row was picked over the other open gaps because its remediation is concrete and self-contained, its verdict is backwards-compatible, and posthog-php'sgetRemoteConfigPayload()already provides a close model within the same contract. Breaking-verdict and Unknown cells were left for humans.Created with PostHog