execDbtCompile / execDbtCompileInline mask real dbt errors with generic wrapper message
Symptom
When dbt compile or dbt compile --inline fails with a real dbt error (e.g. Compilation Error: Model 'foo' depends on a node named 'bar' which was not found), execDbtCompile and execDbtCompileInline in packages/dbt-tools/src/dbt-cli.ts surface a generic wrapper message that masks the actual cause. Users see "Could not compile … Last error: Command failed: …" instead of the structured dbt error they need to fix the problem.
Root cause
Both functions wrap run() in a try { … } catch { lines = [] } that swallows the run-time error entirely:
// execDbtCompile
try {
const { stdout } = await run(args)
lines = parseJsonLines(stdout)
} catch {
lines = []
}
// execDbtCompileInline — same pattern
The structured level: "error" event present in dbt's JSON log on a crashed run is never inspected, and the final throw embeds Node's generic Command failed: … message rather than dbt's category-prefixed error (Compilation Error: …, Database Error: …, etc.).
Expected
Both functions should mirror the pattern already in place for execDbtShow: capture the run error, parse level: "error" events from any partial stdout, and surface the real dbt error via the existing extractDbtError helper (with the same SQL-redaction guarantees provided by fallbackExitMessage).
Suggested fix
Extract a shared runWithErrorBubbling(args, label) helper from the execDbtShow pattern and apply to all three execDbt* functions, so error UX is consistent across the surface.
Related
- #932 / #933 — the same fix was applied to
execDbtShow. Adjacent code path, distinct review surface, hence a separate issue.
Fixed by 32ffe32af in #933. Both execDbtCompile and execDbtCompileInline now capture the run error, skip success-only tiers on crash (same anti-spurious-data reasoning as execDbtShow), and throw via a new shared bubbleDbtError(label, primary, plain) helper. The helper produces a message with the same guarantees as execDbtShow's error UX: structured JSON event > stderr > redacted exit-status, ANSI stripped, no doubled prefix on dbt category errors.