Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception type of run operation macro not found #11193

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changes/unreleased/Under the Hood-20250107-123955.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Under the Hood
body: Change exception type from DbtInternalException to UndefinedMacroError when
macro not found in 'run operation' command
time: 2025-01-07T12:39:55.234321-05:00
custom:
Author: michelleark
Issue: "11192"
3 changes: 1 addition & 2 deletions core/dbt/task/run_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from dbt.node_types import NodeType
from dbt.task.base import ConfiguredTask
from dbt_common.events.functions import fire_event
from dbt_common.exceptions import DbtInternalError

RESULT_FILE_NAME = "run_results.json"

Expand Down Expand Up @@ -86,7 +85,7 @@
unique_id = macro.unique_id
fqn = unique_id.split(".")
else:
raise DbtInternalError(
raise dbt_common.exceptions.UndefinedMacroError(

Check warning on line 88 in core/dbt/task/run_operation.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/run_operation.py#L88

Added line #L88 was not covered by tests
f"dbt could not find a macro with the name '{macro_name}' in any package"
)

Expand Down
4 changes: 2 additions & 2 deletions tests/functional/run_operations/test_run_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
run_dbt_and_capture,
write_file,
)
from dbt_common.exceptions import DbtInternalError
from dbt_common.exceptions import UndefinedMacroError
from tests.functional.run_operations.fixtures import (
happy_macros_sql,
model_sql,
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_macro_exception(self, project):

def test_macro_missing(self, project):
with pytest.raises(
DbtInternalError,
UndefinedMacroError,
match="dbt could not find a macro with the name 'this_macro_does_not_exist' in any package",
):
self.run_operation("this_macro_does_not_exist", False)
Expand Down
Loading