Skip to content

fix(flags): support JSON 3 response parsing - #297

Merged
dustinbyrne merged 1 commit into
mainfrom
fix/ruby-json3-flags
Oct 7, 2026
Merged

dustinbyrne merged 1 commit into
mainfrom
fix/ruby-json3-flags

Conversation

@dustinbyrne

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

JSON 3 rejects the positional options hash passed to JSON.parse in the shared feature-flag request path. In a fresh Rails 8.1 application this causes a successful remote flag evaluation to return nil; definition loading and remote config use the same parser.

Pass symbolize_names: true as keyword arguments, preserving existing JSON 2 behavior while supporting JSON 3. Add a public flag-evaluation regression test that calls the original parser and requires keyword options.

Includes patch changesets for both posthog-ruby and posthog-rails, so Rails users receive the fix through their exact core dependency pin. No public API or default changes.

💚 How did you test it?

  • Regression test: fails before the fix, passes after.
  • bundle exec rspec: 1,255 examples, 0 failures, 2 optional OpenTelemetry tests pending.
  • Full suite with actual JSON 3.0.2 in a separate bundle: 1,255 examples, 0 failures, the same 2 pending.
  • BUNDLE_GEMFILE=gemfiles/otel.gemfile bundle exec rspec: 1,255 examples, 0 failures, no pending.
  • bundle exec rubocop: 129 files, no offenses.
  • bundle exec rake public_api:check: passed.
  • pnpm changeset status: both gems selected for patch releases.
  • Built both gems from a disposable release simulation and verified the packaged Rails dependency pin. A fresh Rails 8.1.4 app with JSON 3.0.2 passed real-transport smoke tests against the local SDK mock server in sync and async modes, including remote flags, capture, automatic exceptions, ActiveJob, OTLP logs, flush, and shutdown.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • Added patch changesets for Ruby and Rails.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Implemented with pi using Git, Ruby/Bundler, Changesets, the SDK mock server, and GitHub CLI. A fresh, read-only pi reviewer found no issues.

@dustinbyrne
dustinbyrne requested a review from a team as a code owner October 7, 2026 19:22
@dustinbyrne dustinbyrne self-assigned this Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

posthog-ruby-sync Compliance Report

Date: 2026-10-07T19:25:02.082576+00:00
Duration: 94031ms

⚠️ Some Tests Failed

45/47 tests passed, 2 failed


Capture Tests

⚠️ 29/30 tests passed, 1 failed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 10ms
Format Validation.Event Has Uuid ✅ 6ms
Format Validation.Event Has Lib Properties ✅ 6ms
Format Validation.Distinct Id Is String ✅ 10ms
Format Validation.Token Is Present ✅ 7ms
Format Validation.Custom Properties Preserved ✅ 7ms
Format Validation.Event Has Timestamp ✅ 7ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 7ms
Retry Behavior.Retries On 503 ✅ 5248ms
Retry Behavior.Does Not Retry On 400 ✅ 2010ms
Retry Behavior.Does Not Retry On 401 ✅ 2011ms
Retry Behavior.Respects Retry After Header ✅ 8015ms
Retry Behavior.Implements Backoff ✅ 15357ms
Retry Behavior.Retries On 500 ✅ 5146ms
Retry Behavior.Retries On 502 ✅ 5151ms
Retry Behavior.Retries On 504 ✅ 5116ms
Retry Behavior.Max Retries Respected ✅ 15461ms
Deduplication.Generates Unique Uuids ✅ 22ms
Deduplication.Preserves Uuid On Retry ✅ 5114ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10353ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5123ms
Deduplication.No Duplicate Events In Batch ✅ 20ms
Deduplication.Different Events Have Different Uuids ✅ 9ms
Compression.Sends Gzip When Enabled ✅ 6ms
Batch Format.Uses Proper Batch Structure ✅ 6ms
Batch Format.Flush With No Events Sends Nothing ✅ 3ms
Batch Format.Multiple Events Batched Together ❌ 17ms
Error Handling.Does Not Retry On 403 ✅ 2009ms
Error Handling.Does Not Retry On 413 ✅ 2010ms
Error Handling.Retries On 408 ✅ 5151ms

Failures

batch_format.multiple_events_batched_together

Expected 1 requests, got 5

Feature_Flags Tests

⚠️ 16/17 tests passed, 1 failed

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 ✅ 6ms
Request Payload.Token In Flags Body Matches Init ✅ 7ms
Request Payload.Groups Round Trip ✅ 7ms
Request Payload.Groups Default To Empty Object ✅ 7ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 9ms
Request Payload.Disable Geoip Omitted Defaults To False ❌ 8ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 7ms
Request Lifecycle.No Flags Request On Init Alone ✅ 3ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 7ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 8ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 7ms
Retry Behavior.Retries Flags On 502 ✅ 151ms
Retry Behavior.Retries Flags On 504 ✅ 111ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 8ms

Failures

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', 'groups', 'person_properties', 'group_properties', 'flag_keys_to_evaluate', 'token']

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

posthog-ruby-async Compliance Report

Date: 2026-10-07T19:25:04.676540+00:00
Duration: 98118ms

⚠️ Some Tests Failed

46/47 tests passed, 1 failed


Capture Tests

✅ 30/30 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 107ms
Format Validation.Event Has Uuid ✅ 105ms
Format Validation.Event Has Lib Properties ✅ 107ms
Format Validation.Distinct Id Is String ✅ 105ms
Format Validation.Token Is Present ✅ 106ms
Format Validation.Custom Properties Preserved ✅ 106ms
Format Validation.Event Has Timestamp ✅ 105ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 8ms
Retry Behavior.Retries On 503 ✅ 5409ms
Retry Behavior.Does Not Retry On 400 ✅ 2108ms
Retry Behavior.Does Not Retry On 401 ✅ 2107ms
Retry Behavior.Respects Retry After Header ✅ 8015ms
Retry Behavior.Implements Backoff ✅ 15520ms
Retry Behavior.Retries On 500 ✅ 5211ms
Retry Behavior.Retries On 502 ✅ 5212ms
Retry Behavior.Retries On 504 ✅ 5211ms
Retry Behavior.Max Retries Respected ✅ 15521ms
Deduplication.Generates Unique Uuids ✅ 109ms
Deduplication.Preserves Uuid On Retry ✅ 5210ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10416ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5213ms
Deduplication.No Duplicate Events In Batch ✅ 110ms
Deduplication.Different Events Have Different Uuids ✅ 107ms
Compression.Sends Gzip When Enabled ✅ 106ms
Batch Format.Uses Proper Batch Structure ✅ 105ms
Batch Format.Flush With No Events Sends Nothing ✅ 3ms
Batch Format.Multiple Events Batched Together ✅ 108ms
Error Handling.Does Not Retry On 403 ✅ 2107ms
Error Handling.Does Not Retry On 413 ✅ 2107ms
Error Handling.Retries On 408 ✅ 5211ms

Feature_Flags Tests

⚠️ 16/17 tests passed, 1 failed

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

Failures

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', 'groups', 'person_properties', 'group_properties', 'flag_keys_to_evaluate', 'token']

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Retrigger

[Medium risk] Fixes feature flag response parsing for JSON 3 compatibility.

The PR appears safe to merge; no actionable issues were found.

Reviews (1) · Last reviewed commit: "fix(flags): support JSON 3 response pars..." · Reviewed by Greptile

@dustinbyrne dustinbyrne mentioned this pull request Oct 7, 2026
4 tasks done
@dustinbyrne
dustinbyrne merged commit 5adef1c into main Oct 7, 2026
25 checks passed
@dustinbyrne
dustinbyrne deleted the fix/ruby-json3-flags branch October 7, 2026 21:03
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