Skip to content

fix: compact nil conditions before marshalling - #47

Merged
johnny-jiang-rewind merged 4 commits into
rewind-community:mainfrom
johnny-jiang-rewind:jj.fix_nil_to_wire
Jul 20, 2026
Merged

fix: compact nil conditions before marshalling#47
johnny-jiang-rewind merged 4 commits into
rewind-community:mainfrom
johnny-jiang-rewind:jj.fix_nil_to_wire

Conversation

@johnny-jiang-rewind

Copy link
Copy Markdown
Contributor

feature_to_hash called .map(&:to_wire) on enabled_for/disabled_for
without stripping nils, so a condition array containing nil raised
undefined method 'to_wire' for nil. The unless …empty? guard only
catches [], not [nil].
Add .compact before each .map(&:to_wire) so stray nil conditions are
dropped instead of blowing up serialization. Regressed in 3.3.0 (#43);
surfaced in rewind-admin's feature-flag update path.

Copilot AI review requested due to automatic review settings July 20, 2026 20:00
@johnny-jiang-rewind
johnny-jiang-rewind requested a review from a team as a code owner July 20, 2026 20:00

@diff-vader-bot diff-vader-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Risk: LOW — no substantive findings

👀 Diff Vader · Needs human review

Council skipped — policy-routed (external contributor — every org requires a human reviewer for non-members).

External contributor — every org requires a human reviewer for PRs from non-members.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the JSON marshaller so feature condition lists containing stray nil entries no longer raise during serialization, addressing a regression where nil.to_wire could crash the update path.

Changes:

  • Compacts enabled_for and disabled_for arrays before mapping conditions to their wire format.
  • Prevents marshalling from blowing up when condition arrays contain nil.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/eight_ball/marshallers/json.rb Outdated
Comment thread lib/eight_ball/marshallers/json.rb Outdated
Comment on lines +108 to +109
hash[:enabled_for] = feature.enabled_for.compact.map(&:to_wire) unless feature.enabled_for.empty?
hash[:disabled_for] = feature.disabled_for.compact.map(&:to_wire) unless feature.disabled_for.empty?
johnny-jiang-rewind and others added 2 commits July 20, 2026 16:03
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@smandegar smandegar self-assigned this Jul 20, 2026
@smandegar

Copy link
Copy Markdown
Contributor

Don't forget to bump the version

@diff-vader-bot diff-vader-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Risk: LOW — no substantive findings

👀 Diff Vader · Needs human review

Council skipped — policy-routed (external contributor — every org requires a human reviewer for non-members).

External contributor — every org requires a human reviewer for PRs from non-members.

@johnny-jiang-rewind
johnny-jiang-rewind merged commit c6597e0 into rewind-community:main Jul 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants