-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[CT-2735] [Bug] Compile query error doesn't include node information #7940
Comments
Thanks for reporting this @ChenyuLInx ! Do you have both the interest and bandwidth to tackle this, or are you hoping another member of the team can dive into it? |
The exception itself has an optional dbt-core/core/dbt/exceptions.py Line 86 in 9836f7b
Not every exception will be associated with a node, but many of them will. Currently, dbt-core/core/dbt/cli/requires.py Lines 87 to 96 in 38ca4fc
We could also include other structured attributes of the node, above all its except DbtException as e:
node_unique_id = None
if hasattr(e, "node"):
unique_id = e.node.unique_id
fire_event(MainEncounteredError(exc=str(e), unique_id=unique_id))
raise ExceptionExit(e) This also requires updating the proto contract of
{
"data": {
"exc": "Compilation Error in sqloperation inline_query (from remote system.sql)\n The name argument to ref() must be a string, got <class 'int'>",
"unique_id": "sqloperation.my_dbt_project.inline_query"
},
"info": {
"category": "",
"code": "Z002",
"extra": {},
"invocation_id": "00255fea-e009-4830-8b46-417bb54fda67",
"level": "error",
"msg": "Encountered an error:\nCompilation Error in sqloperation inline_query (from remote system.sql)\n The name argument to ref() must be a string, got <class 'int'>",
"name": "MainEncounteredError",
"pid": 79540,
"thread": "MainThread",
"ts": "2023-06-24T14:48:44.520796Z"
}
} Better!
|
I went with option 2 but opted for a even narrower fix to fire an event when error happens and re-raise a general error for the main process to handle later on. |
Is this a new bug in dbt-core?
Current Behavior
This might be one symptom of a more general error handling problems in dbt-core.
The specific situation happened here is that when compiling a inline dbt sql, and run into an execption, dbt will fire an event that doesn't contain information about what node run into this issue. See Steps to Repro for command.
This is because uncatched exceptions are catched in
requires.postflight
linked below instead of in the place where we compile query.dbt-core/core/dbt/cli/requires.py
Line 90 in 38ca4fc
Expected Behavior
I would expect the fired event contains information about which node run into issue. for example, maybe the json log looks like
Current issue is because we do not have much exception handling logic in various tasks in general. This is a
dbt-core
general problem.But specifically for this case, we can make sure we handle exception and fire proper event then re raise another exception at
dbt-core/core/dbt/task/compile.py
Line 38 in aecbb45
and
dbt-core/core/dbt/task/compile.py
Line 132 in aecbb45
to fire event that contains node information in place.
Steps To Reproduce
dbt --log-format json compile --inline "select * from {{ref(1)}}"
The text was updated successfully, but these errors were encountered: