Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where the transient error retry logic (from #2125) never fires for
APIDbtRunner(the default runner for dbt >= 1.5.0).Root cause:
APIDbtRunner._inner_run_commandonly capturesJinjaLogInfoandRunningOperationCaughtErrorevents into theoutputfield. When a command fails with a transient error (e.g. Dremio'sRemoteDisconnected), the error text lives inres.exception— not in the captured output. The retry logic in_inner_run_command_with_retrieschecksis_transient_error(adapter_type, output=result.output, stderr=result.stderr), butstderrwas alwaysNonefor APIDbtRunner, so pattern matching never found the transient error string.Fix: Extract
str(res.exception)and pass it as thestderrfield ofAPIDbtCommandResult. The dbt Python API doesn't use stderr, so this repurposes the field analogously to howSubprocessDbtRunnercaptures subprocess stderr.Discovered while investigating this Dremio CI failure.
Review & Testing Checklist for Human
stderrfield consumers: Search for any code that readsresult.stderrfrom anAPIDbtCommandResultand confirm that receiving exception text (instead ofNone) doesn't cause unintended side effects. Thestderrfield is now non-None on failure for the API runner path.stderrfield is being semantically overloaded — it means "subprocess stderr" forSubprocessDbtRunnerand "exception string" forAPIDbtRunner. Would a separateexception_textfield onDbtCommandResultbe cleaner? Current approach works but may confuse future readers.raise_on_failure=Truepath: The change fromstr(res.exception) if res.exception else output→exception_text or outputis semantically equivalent, but the new tests only coverraise_on_failure=False. Confirm the raise path still works as expected (theDbtCommandError.err_msgshould be unchanged).Test Plan
pytest tests/unit/clients/dbt_runner/test_retry_logic.py::TestAPIDbtRunnerTransientDetection -vAPIDbtRunner(e.g. kill a Dremio connection mid-query) and confirm retry firesNotes
raise_on_failure=Truepath was already partially working before this fix (exception text was inDbtCommandError.err_msg), but theraise_on_failure=Falsepath was completely broken for transient detectionSummary by CodeRabbit
Bug Fixes
Tests