A dbt run is a pipeline of four distinct processes, and the error message you see in your terminal is always emitted by exactly one of them. The parser converts YAML files and SQL files into an in-memory graph. The compiler resolves Jinja expressions (ref, source, var, macro) into raw SQL. The adapter wraps the raw SQL into a warehouse-specific DDL or DML statement. The warehouse engine then either accepts the statement or returns a driver error. The single most accelerating habit a dbt developer can build is the reflex of reading every error message in that order: parser, compiler, adapter, warehouse. The token that names the failing layer is always present in the first two lines of the trace, and once the layer is identified the file you must open is usually obvious.
A standard log line for a node failure has three structural parts. The header identifies the node and the failure mode: Failure in model stg_orders (models/staging/stg_orders.sql) followed by a Python exception class. The body carries the message text, which may be a Jinja exception, a CompilationError raised inside dbt, or a DatabaseError that wraps the driver message returned by the warehouse. The footer points at the source file, prints a few lines of compiled SQL when the error is a compile-time issue, and lists timing information. When the failure originated inside a Jinja template, dbt prints a small traceback showing the macro chain that led to the error; when the failure originated in the warehouse, the wrapped driver error is printed verbatim including any vendor-specific error code such as Snowflake's 001003 or BigQuery's Not found: prefix.
The four error classes the dbt runner raises are worth memorizing because they map cleanly to the four layers. ParsingError indicates that YAML or SQL files could not be assembled into a manifest; nothing downstream has run. CompilationError is raised when Jinja resolves successfully but produces SQL that dbt rejects before sending to the warehouse: a missing ref target, an undefined macro, an incremental model with no unique_key when merge is selected. DatabaseError is the catch-all that wraps every warehouse-side rejection: syntax errors, missing tables, permission denials, type mismatches. DbtRuntimeError covers internal failures such as a profile that cannot be loaded, a thread pool exhaustion, or a state directory that does not contain a usable manifest.json. The class name is always the first token on the failure line, and seeing it tells you whether to open a YAML file, a SQL file, a profile, or the warehouse query history.
Log verbosity is controlled by --log-level and the LOG_LEVEL environment variable, with debug printing the rendered SQL of every model along with adapter calls. The lighter info level is the default and prints node start, finish, and failure events without the rendered SQL. Two log files are written to disk on every invocation: logs/dbt.log contains the info-level stream and is safe to share with collaborators, and logs/dbt-debug.log (or whatever log-path resolves to when --debug is set) carries the full debug stream including adapter SQL and connection events. When a CI job fails the first action is almost always to download dbt.log for the failing run; the timestamp pattern at the head of each line lets you correlate a specific node failure with surrounding adapter events.
Multi-node failures complicate triage when threading is high. With --threads 8 and a failure early in the run, the runner will start seven other models before noticing the first failure, and the log will interleave their progress lines with the failure trace. The --fail-fast flag instructs dbt to abort all in-flight models at the first failure, which makes the log readable but discards work that may have been valid. The disciplined pattern is to leave threading high during normal runs, then add --fail-fast when reproducing a known intermittent failure to keep the trace focused. The first failed node printed in the summary is not always the root cause; in a DAG with chained models, an upstream failure can produce downstream errors that complete first because of thread scheduling. Always sort the failed nodes by their position in the DAG (using dbt ls --select <failed>+ --output json) before deciding which one to fix first.
# Increase verbosity for the rendered SQL and adapter call stream
dbt --debug run --select stg_orders
# Limit triage scope and surface the first failure cleanly
dbt run --select tag:critical --fail-fast --threads 1
# Read the most recent error events from the log without re-running
grep -E "Failure|Error|Database Error" logs/dbt.log | tail -50
# Pull the structured run summary that lists every node and its status
cat target/run_results.json | jq '.results[] | select(.status != "success") | {name: .unique_id, status, message}'
The compile error subclass deserves special attention because its message often mentions a SQL token that looks like a warehouse word but originates inside dbt. A failure such as Compilation Error in model fct_orders: model 'model.shop.dim_customer' depends on a node named 'stg_customer' which was not found is raised by the dbt parser when it tries to resolve ref('stg_customer') and fails to locate a matching model file in the project graph. The message contains the word node, which is dbt vocabulary, and model.shop.dim_customer, which is the unique-id form dbt uses internally. Both tokens are tells that the error is dbt Core, not the warehouse. By contrast, a message such as Database Error in model fct_orders: 002003 (42S02): SQL compilation error: Object 'ANALYTICS.STAGING.STG_CUSTOMER' does not exist or not authorized carries Database Error, the Snowflake-specific error code 002003, the ANSI SQLSTATE 42S02, and a fully qualified three-part name; every one of those tokens places the failure inside Snowflake, not dbt.
Failure in model dim_customer (models/marts/dim_customer.sql)
Database Error in model dim_customer (models/marts/dim_customer.sql)
001003 (42000): SQL compilation error:
syntax error line 17 at position 4 unexpected 'SELEC'.
compiled Code at target/run/shop/models/marts/dim_customer.sql
Done. PASS=12 WARN=0 ERROR=1 SKIP=2 TOTAL=15
The pointer compiled Code at target/run/shop/models/marts/dim_customer.sql is the bridge to the next section: when dbt prints that line, it is telling you where to find the exact statement the warehouse received. Following the pointer is the difference between guessing at a Jinja issue and pasting a runnable query into the warehouse console.
💡 Exam Trap: A
Compilation Errorraised by dbt is not the same as a SnowflakeSQL compilation error. The first is dbt Core rejecting the model graph; the second is the warehouse rejecting SQL syntax. The dbt class name (CompilationErrorvsDatabaseError) is the only reliable signal; both messages contain the substringcompilation error.
💡 Exam Trap: With
--threadsgreater than one, the order of failed nodes in the summary reflects scheduling order, not DAG depth. The first node listed in the failure block is not always the upstream cause. Usedbt ls --select <failed>+ --output jsonto find the topological root before applying a fix.
⚠️ Anti-Pattern: Suppressing log noise by piping through
grep ERROR. The grep filter loses the surrounding adapter events and thecompiled Code atpointer line, which is the most useful piece of the trace. Read the full log file or usejqagainstrun_results.jsoninstead.
🎯 Scenario: A CI run reports two failed models:
dim_productandfct_sales. The build log showsdim_productfailing with aDatabase Errorreferencing a missing columncategory_id, andfct_salesfailing with aDatabase Errorreferencing a missing tableanalytics.staging.dim_product. The root cause is thedim_productmodel: its compiled SQL did not produce acategory_idcolumn, sodim_productrebuild failed, which left the stale (or absent) table thatfct_salesthen could not read. The fix targetsdim_productonly; rerunning withdbt build --select dim_product+rebuilds both.
📊 Limit: A single dbt log file (
logs/dbt.log) is appended to on every invocation. Without a log rotation strategy the file grows without bound. dbt Cloud Jobs retain logs per run for the project retention window (verify the live retention value on the dbt Cloud admin page).
The Decision Anchor for log reading is the layer token. Choose to open a YAML file when the error class is ParsingError. Choose to open a SQL file when the error class is CompilationError and the message names a ref or source target. Choose to open target/run/ and the warehouse console when the error class is DatabaseError. Choose to open profiles.yml or the dbt Cloud environment when the error class is DbtRuntimeError and the message mentions a connection or credential.
