Skip to content

Commit

Permalink
Fix exception type of run operation macro not found (#11193)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk authored Jan 8, 2025
1 parent 2eb1a5c commit 57e279c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
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 @@ def run(self) -> RunResultsArtifact:
unique_id = macro.unique_id
fqn = unique_id.split(".")
else:
raise DbtInternalError(
raise dbt_common.exceptions.UndefinedMacroError(
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

0 comments on commit 57e279c

Please sign in to comment.