Repository navigation
Fixes 35886: Read dbt Cloud run_results.json from every run step - #35887
Conversation
The artifacts endpoint serves only the last step's files when no step is given, so a job whose dbt test is not its final command (e.g. docs generate runs after it) lost every test result. Request run_steps with the run and fetch run_results.json per step.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
|
The Python checkstyle failed. Please run You can install the pre-commit hooks with |
| except Exception as exc: | ||
| logger.debug(f"No dbt run_results for run {run_id} step {step_index}: {exc}") | ||
| continue |
There was a problem hiding this comment.
If one step's artifact request raises an unexpected error, such as an HTTP 500, while another step succeeds, the helper returns incomplete results without a warning. The old fetch warned on exceptions. Here, failures are logged only at debug level, and the final warning appears only when every step is missing.
Keep expected missing artifacts quiet, but warn on unexpected failures with the run and step IDs. Add a test where one request fails and another succeeds.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prunes the G004 baseline entry for the f-string the step fetch replaced.
Code Review ✅ Approved🟡 Medium risk · Fetching run_results.json from every dbt Cloud step changes ingested results; step-level artifact handling could omit or misattribute test outcomes. Reads dbt Cloud VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
🚦 Removed from the merge queue —
|



Describe your changes:
Fixes #35886
dbt Cloud's artifacts endpoint serves the last step's files when no
stepis given. So when a job'sdbt testis not its final command, every dbt test result is lost: for example, when "Generate docs on run" adds adbt docs generatestep after it, or whendbt testis followed bydbt run. The runs request now asks forinclude_related=["run_steps"], andrun_results.jsonis fetched for each step. Steps with no artifacts (clone, profile, deps) are skipped. A run with no step details falls back to the old last-step request. The existing multi-file handling (_get_latest_result) already drops compile-only entries and picks the newestexecuteresult, so results from several steps merge correctly.Type of change:
High-level design:
N/A — small change (2 files).
Tests:
Use cases covered
dbt testas step 7 of 8: test results from step 7 and model results from step 8 are both returned (onmainonly step 8 was read).run_stepsin the response: falls back to the endpoint's default (the last step).run_results.json: tests are skipped (dbt_run_results is None), and ingestion carries on.Unit tests
ingestion/tests/unit/test_dbt_config_errors.py(TestDbtCloudRunResultsSteps, 3 tests)PYTHONPATH=src python -m pytest tests/unit/test_dbt_config_errors.py tests/unit/test_dbt_http_config.py tests/unit/test_dbt.py→ 281 passed (every unit test that importsdbt_config)dbt_config.py: 73% (the dbt Cloud path changed here is covered; the S3/GCS/Azure/HTTP readers make up most of the uncovered lines)test_reads_run_results_from_every_stepfails againstmain'sdbt_config.py, fails wheninclude_relatedis removed, and fails when theisinstance(result, dict)guard is removed.Backend integration tests
Ingestion integration tests
tests/integration/suite covers dbt Cloud config fetching (none importsdbt_config).Playwright (UI) tests
Manual testing performed
Not run against a live dbt Cloud account. Behaviour is verified with unit tests that mimic the dbt Cloud API: steps are listed only when
include_relatedasks for them, and a missing step artifact comes back as aNonebody.UI screen recording:
Not applicable — backend ingestion fix, no UI.
Checklist:
I have read the CONTRIBUTING document.
My PR title is
Fixes <issue-number>: <short explanation>My PR is linked to a GitHub issue via
Fixes #<issue-number>above.I have commented on my code, particularly in hard-to-understand areas.
For JSON Schema changes: I updated the migration scripts or explained why it is not needed. — N/A, no schema change
For a UI feature or feature task: … — N/A, no UI
I have added tests (unit / integration / Playwright as applicable) and listed them above.
Self-review: I reviewed the final diff against
REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.48ab405: no 🔴. 🟡 fixed in512aae1(a test-only change, verified by mutation): the test fake now returnsNonefor a missing step artifact, as the real REST client does. 🟡 answered: results with noexecutetiming (skipped tests) still fall back to the first run_results file'sgenerated_at(metadata.py:978). That rule already exists for multi-file S3 runs; per-file timestamps are left as a follow-up.Decision check: no durable decision; this is a bug fix.
I have added a test that covers the exact scenario we are fixing.
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge, with the previous non-blocking warning issue still open.Findings
Summary
Reads dbt Cloud’s
run_results.jsonfrom every listed run step.No new findings were identified in the changes since the previous review.
Reviews (2) · Last reviewed commit: "style(dbt): use lazy %-style logging in ..." · Reviewed by Greptile