Skip to content

Fix question update corrupting v0.59+ cards with template tags#17

Merged
rohanraarora merged 1 commit into
release/v0.6.1from
fix/question-update-v059-template-tags
Apr 20, 2026
Merged

Fix question update corrupting v0.59+ cards with template tags#17
rohanraarora merged 1 commit into
release/v0.6.1from
fix/question-update-v059-template-tags

Conversation

@rohanraarora

Copy link
Copy Markdown
Owner

Summary

  • Fixes question update corrupting v0.59+ cards whenever template tags are involved. The update path wrapped stages[0].native as {query, template-tags}; Metabase saved it but the query processor couldn't substitute parameters, leaving cards unrunnable (Card does not have a template tag named X / No matching clause).
  • Rewrites the stages-format branch to keep native as a string and put template-tags at the stage level, matching native-UI-authored cards. Extracted as a pure helper buildDatasetQueryUpdate in src/commands/question.ts.
  • Adds 7 regression tests in test/question-update.test.ts covering both v0.59+ stages and legacy shapes, including the exact corrupted-card payload from the repro.
  • Cards previously corrupted by this bug heal automatically on their next update (nested-object native is unwrapped back to a string).

Test plan

  • npm run typecheck
  • npm run lint (no new warnings)
  • npm run format:check
  • npm test — 123/123 passing (7 new)
  • End-to-end on live metabase.codingninjas.com v0.59.4: reproduced corruption pre-fix; post-fix, create → update with tags → run → second update → run all succeed; stored dataset_query matches native UI shape
  • Audited other v0.59+ payload paths (question create, query run, exports, reads) — all healthy

🤖 Generated with Claude Code

The update path wrapped stages[0].native as {query, template-tags}. Metabase
v0.59+ saved the object but the query processor failed to substitute
parameters, leaving the card unrunnable. Now emits native as a string with
template-tags at the stage level, matching native-UI-authored cards. Also
heals cards previously corrupted by this bug on next update.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rohanraarora rohanraarora merged commit 2b46dc8 into release/v0.6.1 Apr 20, 2026
3 checks passed
@rohanraarora rohanraarora mentioned this pull request Apr 20, 2026
5 tasks
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