Skip to content

Fixes 35886: Read dbt Cloud run_results.json from every run step - #35887

Merged
anuj-kumary merged 3 commits into
mainfrom
ulixius9/dbt-artifacts-read-steps
Oct 22, 2026
Merged

anuj-kumary merged 3 commits into
mainfrom
ulixius9/dbt-artifacts-read-steps

Conversation

@ulixius9

@ulixius9 ulixius9 commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #35886

dbt Cloud's artifacts endpoint serves the last step's files when no step is given. So when a job's dbt test is not its final command, every dbt test result is lost: for example, when "Generate docs on run" adds a dbt docs generate step after it, or when dbt test is followed by dbt run. The runs request now asks for include_related=["run_steps"], and run_results.json is 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 newest execute result, so results from several steps merge correctly.

Type of change:

  • Bug fix

High-level design:

N/A — small change (2 files).

Tests:

Use cases covered

  • dbt Cloud job with dbt test as step 7 of 8: test results from step 7 and model results from step 8 are both returned (on main only step 8 was read).
  • Run with no run_steps in the response: falls back to the endpoint's default (the last step).
  • No step has a run_results.json: tests are skipped (dbt_run_results is None), and ingestion carries on.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated: 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 imports dbt_config)
  • Coverage on 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)
  • Mutation checks: test_reads_run_results_from_every_step fails against main's dbt_config.py, fails when include_related is removed, and fails when the isinstance(result, dict) guard is removed.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable: no tests/integration/ suite covers dbt Cloud config fetching (none imports dbt_config).

Playwright (UI) tests

  • Not applicable (no UI changes).

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_related asks for them, and a missing step artifact comes back as a None body.

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 (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.

    • Reviewed 48ab405: no 🔴. 🟡 fixed in 512aae1 (a test-only change, verified by mutation): the test fake now returns None for a missing step artifact, as the real REST client does. 🟡 answered: results with no execute timing (skipped tests) still fall back to the first run_results file's generated_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

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with the previous non-blocking warning issue still open.

Findings

  1. P2 Failed steps go unnoticed ▶

Summary

Reads dbt Cloud’s run_results.json from every listed run step.

  • dbt Cloud ingestion collects run results from every 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

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.
@ulixius9
ulixius9 requested a review from a team as a code owner October 21, 2026 11:21
@ulixius9
ulixius9 requested review from mohittilala and a balanced review from Copilot October 21, 2026 11:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This 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 skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The Python checkstyle failed.

Please run make py_format and py_format_check in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Python code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

Comment on lines +381 to +383
except Exception as exc:
logger.debug(f"No dbt run_results for run {run_id} step {step_index}: {exc}")
continue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Failed steps go unnoticed

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.
Copilot AI balanced review requested due to automatic review settings October 22, 2026 05:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitar-bot

gitar-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown
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 run_results.json from every run step instead of only the last step, so dbt test results are kept when they are not the final command in a job. Steps without artifacts are skipped, and runs without step details fall back to the previous last-step request. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

@harshsoni2024
harshsoni2024 added this pull request to the merge queue Oct 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-22T12:07:21Z)

Blocked the queue: playwright-summary

Failed Playwright tests:

  • Features/Glossary/LargeGlossaryPerformance.spec.ts › should search and filter glossary terms

@anuj-kumary
anuj-kumary added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit fcaf759 Oct 22, 2026
90 of 93 checks passed
@anuj-kumary
anuj-kumary deleted the ulixius9/dbt-artifacts-read-steps branch October 22, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dbt Cloud: test results lost when dbt test is not the job's last step

4 participants