Skip to content

Fix 500 on the preview screen for heterogeneous item bags - #120

Merged
loevgaard merged 1 commit into
1.xfrom
fix/preview-heterogeneous-bags
Jul 2, 2026
Merged

loevgaard merged 1 commit into
1.xfrom
fix/preview-heterogeneous-bags

Conversation

@loevgaard

Copy link
Copy Markdown
Member

Bug: /admin/feeds/{id}/preview threw Key "g:item_group_id" ... does not exist for feeds whose sampled items don't all carry every output key (e.g. g:item_group_id exists only for multi-variant products). The included-sample table iterates the union of all items' keys, and bag[column] on a missing key throws under strict_variables (dev + the test app).

Fix: null-coalesce the cell lookup (bag[column] ?? null) so a missing column renders an empty cell.

Test: PreviewTemplateTest renders the real template under strict_variables with a mix of items that do and don't carry a column — it reproduces the exact exception on the pre-fix template and passes on the fix.

Verified in the browser against the running test app (feed 2, previously 500, now renders).

The included-sample table iterates the UNION of every sampled item's output keys, but
item bags are heterogeneous — e.g. g:item_group_id is only set for multi-variant
products. Accessing bag[column] for a column a given row doesn't carry throws
'Key "..." does not exist' under strict_variables (dev + the test app). Null-coalesce
the lookup (bag[column] ?? null) so a missing column renders an empty cell.

Regression test renders the real template under strict_variables with a mix of items
that do and don't carry a column (it reproduces the exact exception on the old
template).
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.17%. Comparing base (38220d0) to head (00b4990).
⚠️ Report is 3 commits behind head on 1.x.

Additional details and impacted files
@@            Coverage Diff            @@
##                1.x     #120   +/-   ##
=========================================
  Coverage     92.17%   92.17%           
  Complexity     1727     1727           
=========================================
  Files           228      228           
  Lines          4382     4382           
=========================================
  Hits           4039     4039           
  Misses          343      343           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loevgaard
loevgaard merged commit f453500 into 1.x Jul 2, 2026
29 of 30 checks passed
@loevgaard
loevgaard deleted the fix/preview-heterogeneous-bags branch July 2, 2026 21:10
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.

1 participant