Skip to content

[Bug] Callback exceptions won't propagate #11612

@mmenjivarST

Description

@mmenjivarST

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

When a callback configured for a programmatic execution using the dbtRunner class fails, the exception doesn't propagate to the main thread. Instead, the dbt execution doesn't understand that the callback failed and keeps waiting for the process indefinitely

from dbt_common.events.base_types import EventMsg

def print_version_callback(event: EventMsg):
  if event.info.name == "NodeFinished":
    try:
      1/0
    except:
      traceback.print_exc()
      raise Exception("This should let continue the execution registering the failure")

dbt = dbtRunner(callbacks=[print_version_callback])
dbt.invoke(dbt_commands)

Expected Behavior

Exceptions are propagated to the main thread, and callback failures are handled correctly

Steps To Reproduce

  1. Create a callback that will fail, using the NodeFinished event name
  2. Attach the callback to a dbtRunner instance
  3. Run dbt commands

Relevant log output

Environment

- OS: Ubuntu 24.04.2 LTS
- Python: 3.12.3
- dbt: 1.9.4

Which database adapter are you using with dbt?

spark

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions