MetricSign
EN|NLRequest Access
Medium severityconfiguration

Power BI Refresh Error:
HookRunError (on-run-end)

What does this error mean?

A SQL statement or macro defined in the on-run-end hook in dbt_project.yml failed to execute. dbt runs on-run-end hooks after all selected nodes complete, so a hook failure is reported even when all models succeeded.

Common causes

  • 1A SQL statement in on-run-end references a table or view that does not exist in the current target schema
  • 2A macro called from on-run-end raises an exception (e.g. Jinja rendering failure or undefined variable)
  • 3The database user running dbt lacks GRANT or DDL permissions required by the hook SQL
  • 4The hook SQL is valid in the development target but not in production (different schema names or warehouse settings)
  • 5An on-run-end hook calls dbt_utils.grant_select_on_schemas and the schema list is empty or malformed

How to fix it

  1. 1Run the hook SQL manually in the target database to reproduce and isolate the error.
  2. 2Check that all object references in the hook SQL use fully qualified names or target-agnostic Jinja variables like {{ target.schema }}.
  3. 3Verify the dbt runner has the required database permissions for any DDL or GRANT statements in the hook.
  4. 4Add {{ if execute }} guards if the hook references results() — this prevents the hook from running during dbt compile.
  5. 5Use dbt debug to validate the connection and environment before re-running the full job.

Frequently asked questions

Does an on-run-end failure stop the models from running?

No. dbt runs on-run-end hooks after all models complete. A hook failure does not prevent models from executing — but it does cause the overall dbt run to exit with a failure status.

How do I access run results inside an on-run-end hook?

Use the results context variable in on-run-end: {% for res in results %} — this gives you each node's status, execution time, and rows affected. Note: results is only available in on-run-end, not on-run-start.

Other configuration errors