<@U088WCP3B4P> elementary hooks error
# ask-elementary-ai
s
@kapa.ai elementary hooks error
k
Here's an overview of common Elementary
on-run-end
hook errors and their solutions: ------------------------- Common Elementary Hook Errors 1.
'None' has no attribute 'get'
(Compilation Error)
This can occur randomly when running
dbt docs generate
with Airflow. As a workaround, you can disable the Elementary hook uploads via vars: [Slack thread]
Copy code
vars:
  disable_run_results: true
  disable_tests_results: true
  disable_dbt_invocation_autoupload: true
Or disable Elementary entirely for specific targets:
Copy code
models:
  elementary:
    +schema: "elementary"
    +enabled: "{{ target.name in ['prod'] }}"
------------------------- 2.
Inconsistent number of values in VALUES clause
(Column Mismatch)
This happens when an Elementary package update adds a column but the model hasn't been rebuilt. Fix it by running: [Slack thread]
Copy code
dbt run -s elementary
------------------------- 3. Concurrent Job Conflicts (Error code 1023 / DML rate limits) When multiple dbt jobs finish simultaneously, their Elementary hooks can conflict. Solutions: [Slack thread] • Space out job timings so they don't write simultaneously. • Decouple Elementary writes by disabling auto-updates and running them separately:
Copy code
models:
  elementary:
    +schema: elementary
    edr:
      +enabled: "{{ var('enable_elementary_models', false) }}"
Then run Elementary models explicitly:
Copy code
dbt run --select elementary --vars '{enable_elementary_models: true}'
------------------------- 4.
cannot insert multiple commands into a prepared statement
This can be caused by large batch inserts or concurrency issues. Try chunking inserts: [Slack thread]
Copy code
vars:
  insert_rows_method: chunk
  dbt_artifacts_chunk_size: 5000
Or disable the columns autoupload as a hotfix:
Copy code
vars:
  disable_dbt_columns_autoupload: true
------------------------- 5. Hook Not Running After
dbt test
The Elementary
on-run-end
hook should run after both
dbt run
and
dbt test
. If it doesn't run after
dbt test
, ensure the Elementary tables exist in your target schema by running: [Slack thread]
Copy code
dbt run --select elementary --target <your_target>
------------------------- Debugging Tips To get more visibility into what the hook is doing, enable debug logs: [Slack thread]
Copy code
dbt run --vars '{debug_logs: true}'
Then review your
dbt.log
file for details on where the failure occurs. šŸ‘ 0 button šŸ‘Ž 0 button ā„¹ļø Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.
s
@kapa.ai concurrency issue where two dbt runs hit Elementary's monitoring table at the same time and one transaction gets aborted
k
This is a well-known issue with Elementary. When two dbt jobs finish simultaneously, their
on-run-end
hooks both attempt to write to the same Elementary tables (e.g.,
dbt_models
), causing one transaction to be aborted. [BQ concurrency] Recommended Solutions Option 1: Disable Artifact Autoupload (Most Common Fix) Add this to your `dbt_project.yml`:
Copy code
vars:
  disable_dbt_artifacts_autoupload: true
Then run artifacts separately in a controlled, non-concurrent job:
Copy code
dbt run --select elementary.edr.dbt_artifacts
This removes the conflicting writes from the
on-run-end
hook while still allowing test results and invocation data to be uploaded. [BQ concurrent updates] > Note:
disable_dbt_artifacts_autoupload
only disables artifact uploads (#3 of the hook). Test results and invocation data are controlled by separate variables (
disable_run_results
,
disable_tests_results
,
disable_dbt_invocation_autoupload
). Invocation uploads are insert-only and are generally safe from this conflict. [BQ concurrent updates] ------------------------- Option 2: Fully Decouple Elementary Writes Disable Elementary models from running during normal `dbt run`:
Copy code
models:
  your_project:
    +materialized: table
  elementary:
    +schema: elementary
    edr:
      +enabled: "{{ var('enable_elementary_models', false) }}"
Then update Elementary tables in a dedicated, serial job:
Copy code
dbt run --select elementary --vars '{enable_elementary_models: true}'
This ensures only one process ever writes to Elementary tables at a time. [parallel jobs guidance] ------------------------- Option 3: Serialize via Airflow Pools If you use Airflow, use a pool with a single slot for tasks that trigger Elementary hooks, ensuring only one dbt job writes to Elementary at a time. [BQ concurrency] ------------------------- Option 4: Remove Hooks from Long-Running Models If specific long-running models are tying up transactions on Elementary tables, you can remove the post-hooks from those models — especially if they don't need to be tracked in Elementary. [Slack thread] ------------------------- The Elementary team's official troubleshooting guide also covers this: docs.elementary-data.com/oss/general/troubleshooting#error-when-trying-to-run-parallel-dbt-jobs. šŸ‘ 0 button šŸ‘Ž 0 button ā„¹ļø Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.
s
@kapa.ai explain option 1 more simple pls
k
Sure! Here's a simpler explanation of Option 1: What's the problem? Every time a dbt run finishes, Elementary's
on-run-end
hook automatically writes project metadata (like your models, tests, sources) to tables such as
dbt_models
. If two dbt runs finish at the same time, both hooks try to update the same table simultaneously — and one of them fails. [BQ concurrent updates] The fix Step 1: Turn off the automatic metadata upload by adding this to your `dbt_project.yml`:
Copy code
vars:
  disable_dbt_artifacts_autoupload: true
This stops the hook from writing project metadata after every run, so there's no more conflict. Step 2: Update the metadata manually (or on a schedule) by running:
Copy code
dbt run --select elementary.edr.dbt_artifacts
You only need to run this when your project actually changes (e.g., after merging a PR with new models or tests). [on-run-end hooks] What you don't lose This only disables the metadata upload. Your test results and run results will still be collected automatically after every run — so your Elementary monitoring stays intact. [on-run-end hooks] šŸ‘ 0 button šŸ‘Ž 0 button ā„¹ļø Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.
s
What if I just do the step 1 ? @kapa.ai
k
If you only set
disable_dbt_artifacts_autoupload: true
without ever running Step 2, here's what happens: • The concurrency conflict is resolved — the hook no longer writes project metadata on every run, so the transaction conflict goes away. āœ… • Test results and run results still upload — your Elementary monitoring continues to work normally. āœ… • Your project metadata becomes stale — tables like
dbt_models
,
dbt_tests
, and
dbt_sources
will no longer be updated. This means Elementary's report and alerts may show outdated information about your project structure (e.g., old model names, removed tests still appearing). āš ļø [on-run-end hooks] So it's fine as a quick fix to stop the errors, but you should still run Step 2 at least once (and again whenever your project changes) to keep the metadata current. [reduce on-run-end time] šŸ‘ 0 button šŸ‘Ž 0 button ā„¹ļø Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.
s
@kapa.ai I want to stop the alerts for now
k
To stop Elementary alerts, you can use the following variables in your
dbt_project.yml
under the
vars
key:
Copy code
vars:
  disable_model_alerts: true
  disable_test_alerts: true
  disable_warn_alerts: true
After adding these, re-run the Elementary models to apply the changes: [disable alerts]
Copy code
dbt run -s elementary
> Important: Make sure the vars are placed directly under the top-level
vars
key, not nested under any model or package section. [correct placement] If you want to re-enable alerts later, simply set those vars back to
false
and re-run
dbt run -s elementary
. šŸ‘ 0 button šŸ‘Ž 0 button ā„¹ļø Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.