fix(engine): drop never-gated hidden array items instead of null holes - #1217
Merged
Conversation
Hiding an array item wraps it in a multivariate flag gated by a `never` matcher; flag.ts returns `undefined` when no variant matched. The engine left that `undefined` as a hole in the resolved array, which serializes to `null` in JSON and renders as an empty card (blank benefit rows, etc.). Compact `undefined` out of resolved arrays in resolvePropsWithHints. A resolver returning `null` is a legitimate value and is kept — only the `undefined` "not present" sentinel is filtered. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Tagging OptionsShould a new tag be published when this PR is merged?
|
📝 WalkthroughWalkthroughArray resolution now removes ChangesArray resolution
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Address review feedback: - Only reallocate when the array actually contains `undefined` (scan with `includes` first) so the common zero-undefined case skips the extra allocation on the hot resolve path. - Reframe the comment around the generic invariant (object props already drop `undefined` under JSON.stringify; array `undefined` serializes to a `null` hole — compaction makes arrays consistent), citing the never-gated flag as the motivating case rather than the definition. - Add tests: all-items-hidden -> [], and nested-array multi-depth (with a first-element drop to pin ordering). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hugo-ccabral
approved these changes
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Same fix as the blocks runtime, ported to the deco engine.
Hiding an array item wraps it in a multivariate flag gated by a
nevermatcher.blocks/flag.tsreturnsmatch?.value→undefinedwhen no variant matched. The engine'sresolvePropsWithHintswrote thatundefinedback into the resolved array (mutableProps[index] = undefined), leaving a hole that serializes tonullin JSON and renders as an empty card (blank benefit rows, empty banners, etc.).Fix (
engine/core/resolver.ts)Compact
undefinedout of resolved arrays before returning. A resolver returningnullis a legitimate value and is kept — only theundefined"not present" sentinel is filtered.Testing
Reproduced empirically first (array with a resolver returning
undefined→ serialized to[...,null,null]), then confirmed the fix drops the holes.Added a regression step to
engine/core/mod.test.ts(drops hidden array items (resolver -> undefined) but keeps null). Fullresolvesuite: 8/8 steps pass.deno fmt/deno lintclean.🤖 Generated with Claude Code
Summary by cubic
Drop hidden array items in the engine instead of leaving null holes. Prevents empty cards from
undefinedentries and skips extra work when arrays have no hidden items.undefinedfrom resolved arrays; only reallocate if the array containsundefined. Preservenull.[], nested arrays drop hidden items, andnullis kept.Written for commit a6f2afd. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
undefined, avoiding empty slots in results.nullvalues so they remain intact in array outputs.Tests