fix: compact nil conditions before marshalling - #47
Conversation
diff-vader-bot
left a comment
There was a problem hiding this comment.
🟢 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.
There was a problem hiding this comment.
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_foranddisabled_forarrays 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.
| 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? |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Don't forget to bump the version |
diff-vader-bot
left a comment
There was a problem hiding this comment.
🟢 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.
feature_to_hash called
.map(&:to_wire)on enabled_for/disabled_forwithout stripping nils, so a condition array containing nil raised
undefined method 'to_wire' for nil. Theunless …empty?guard onlycatches [], not [nil].
Add
.compactbefore each.map(&:to_wire)so stray nil conditions aredropped instead of blowing up serialization. Regressed in 3.3.0 (#43);
surfaced in rewind-admin's feature-flag update path.