Skip to content

Truncate Metabase API errors; add --verbose for full bodies#18

Merged
rohanraarora merged 1 commit into
release/v0.6.1from
fix/truncate-api-errors
Apr 20, 2026
Merged

Truncate Metabase API errors; add --verbose for full bodies#18
rohanraarora merged 1 commit into
release/v0.6.1from
fix/truncate-api-errors

Conversation

@rohanraarora

Copy link
Copy Markdown
Owner

Summary

  • Metabase returns 5–20 KB Clojure stacktraces for most 500s (via, trace, data, stacktrace). Printing those verbatim blew the LLM context window when driving the CLI from Claude.
  • Errors now extract the top-level message / error / cause (or a flattened errors field-map for validation errors) into a one-line summary. Raw body still available via --verbose or METABASE_CLI_VERBOSE=1.
  • Applies to both HTTP errors (new ApiError class replaces bare throw new Error) and in-band query-execution failures (result.status === "failed").

Measured impact (live on v0.59.4)

Scenario Before After --verbose
500 query-exec failure ~15 KB 71 B full body
400 validation ~300 B 62 B full body
500 template-tag corruption ~15 KB ~150 B full body
404 card ~20 B 33 B same

Test plan

  • npm run typecheck
  • npm run lint (no new warnings)
  • npm run format:check
  • npm test — 145/145 passing (14 new in test/errors.test.ts)
  • End-to-end on live metabase.codingninjas.com v0.59.4: verified short-form output for 404, 400 validation, 500 QP failures, 500 template-tag corruption; verified --verbose and METABASE_CLI_VERBOSE=1 both print full bodies

🤖 Generated with Claude Code

Metabase returns 5-20 KB Clojure stacktraces for most 500s. Printing the full
body on every failure blew the LLM context window when driving the CLI from
Claude. Errors now extract the top-level message/error/cause (or compact
validation errors) into a one-line summary. The raw body is still available
via --verbose or METABASE_CLI_VERBOSE=1.

Applies to both HTTP errors (via new ApiError class) and in-band query
execution failures.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rohanraarora rohanraarora force-pushed the fix/truncate-api-errors branch from e3bf3c5 to 7284358 Compare April 20, 2026 10:22
@rohanraarora rohanraarora merged commit dec5598 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