Skip to content

fix(analytics): SelectedVariant#to_h recurses into FallbackReason (SDK-125)#165

Merged
tylerjroach merged 2 commits into
masterfrom
fix/sdk-125-to-h-nested-fallback-reason
Jul 21, 2026
Merged

fix(analytics): SelectedVariant#to_h recurses into FallbackReason (SDK-125)#165
tylerjroach merged 2 commits into
masterfrom
fix/sdk-125-to-h-nested-fallback-reason

Conversation

@tylerjroach

Copy link
Copy Markdown
Contributor

Summary

  • SelectedVariant#to_h was returning @fallback_reason as the raw FallbackReason object instead of the {kind:, message:} hash the class itself defines. Downstream serializers (.to_json, structured logging) got the object's inspect representation.
  • One-line fix — @fallback_reason&.to_h (nil-safe covers matched variants where the field is nil).
  • New spec file spec/mixpanel-ruby/flags/types_spec.rb covering direct hash form, JSON round-trip, and nil-fallback compaction.

Follow-up to SDK-79 caught by Greptile immediately after PR #153 merged.

Test plan

  • bundle exec rspec spec/mixpanel-ruby/flags/types_spec.rb — 4 pass on this branch, 2 fail on master (round-trip + nested-hash assertions)
  • bundle exec rspec spec/mixpanel-ruby/flags/ — full 99-test flag suite green

Linear: SDK-125

The parent to_h was returning @fallback_reason as the raw
FallbackReason object rather than the {kind:, message:} hash the
FallbackReason class itself defines. Downstream serializers
(to_json, structured logging, cross-process passing) received the
object's inspect representation instead of the intended hash.

Fix: `@fallback_reason&.to_h` — the nil-safe form covers matched
variants where fallback_reason is nil.

Added spec/mixpanel-ruby/flags/types_spec.rb covering the direct
hash form, the JSON round-trip, and the nil-fallback compaction
path. All three of the new cases fail on master; all pass now.
@tylerjroach
tylerjroach requested review from a team and tdumitrescu July 21, 2026 03:37
@linear-code

linear-code Bot commented Jul 21, 2026

Copy link
Copy Markdown

SDK-125

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

This looks safe to merge.

  • The updated conversion resolves the fallback-reason serialization failure.
  • Direct fallback_reason access remains unchanged.
  • No blocking issues were found in the changed code.

Important Files Changed

Filename Overview
lib/mixpanel-ruby/flags/types.rb Serializes the optional fallback reason through its existing to_h method.
spec/mixpanel-ruby/flags/types_spec.rb Covers matched variants, nested fallback hashes, JSON output, and absent fallback reasons.

Reviews (2): Last reviewed commit: "Merge branch 'master' into fix/sdk-125-t..." | Re-trigger Greptile

@tylerjroach tylerjroach changed the title fix(flags): SelectedVariant#to_h recurses into FallbackReason (SDK-125) fix(analytics): SelectedVariant#to_h recurses into FallbackReason (SDK-125) Jul 21, 2026
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@022417b). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #165   +/-   ##
=========================================
  Coverage          ?   97.25%           
=========================================
  Files             ?       15           
  Lines             ?      764           
  Branches          ?        0           
=========================================
  Hits              ?      743           
  Misses            ?       21           
  Partials          ?        0           
Flag Coverage Δ
openfeature 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tylerjroach
tylerjroach enabled auto-merge (squash) July 21, 2026 14:19
@tylerjroach
tylerjroach merged commit 76d0695 into master Jul 21, 2026
13 checks passed
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