Repository navigation
[2.0] Fixes #22769: Ingest dbt Cloud artifacts from multiple jobs (#36596) - #37987
Conversation
* dbt Cloud: ingest from multiple jobs or all jobs Accept comma-separated dbt Cloud job IDs and add an opt-in dbtCloudIngestAllJobs flag that reads the latest completed run of every non-CI job. With no job IDs and the flag off, the single most recent run is read, as before. * dbt Cloud: merge job artifacts per environment Each job's manifest lists every model but only carries compiled SQL for the models that job built, so processing jobs one by one let a partial job blank out a full one. Merge the artifacts of jobs sharing an environment, preferring compiled nodes; skip jobs whose runs call fails for reasons other than auth, and keep the default path's messages. * dbt Cloud: skip only jobs without a run; merge one environment at a time Skipping every non-auth failure let a 429 or dbt Cloud's nested-status 401 drop a job silently and blank the models only it compiled. Skip only jobs with no completed run, retry 429, and download, merge and yield one environment at a time. Add the decision record. * dbt Cloud: fail a merge on any failed artifact; newest run wins ties In merge mode, fetch catalog and run_results with get_raw so only a 404 reads as absent; get also returns None after exhausting retries. Merge each environment's runs newest first. Cover the 429 retry with a test that drives the real REST client. * dbt Cloud: refuse to merge manifests of different dbt versions A job can override its environment's dbt version, and the manifest parser validates every node against the merged manifest's one schema version. Fail naming both jobs instead. Name the job and run when a merge finds no manifest, and warn when the default path gets no catalog. * dbt Cloud: newest manifest decides the merged nodes Unioning nodes let a paused job's old run bring back models removed since, and replace a node's current config with an old one. Keep the newest run's nodes and only fill in compiled fields from older runs. Read a duplicated job ID once and warn once on a missing catalog. * dbt Cloud: a broken job skips only its environment Tested on a real account: an abandoned ad-hoc job whose last run failed at dbt seed has no manifest, and failing the whole scan on it would leave every later environment un-ingested. Leave that environment out, ingest the others, then fail the run naming the skipped environments. * docs: rewrap dbt Cloud multi-job decision record * Update generated TypeScript types and dereferenced schemas * dbt Cloud: an unreadable artifact skips only its environment A transport failure or a non-JSON body on a merged run's artifact escaped the per-environment guard and ended ingestion of every later environment. Both are now raised as DBTConfigException where the artifact is fetched. The decision record now says only listing jobs or runs fails at once; an artifact denied to the token skips its environment like any other failure. Also fixes CI: lazy %-style logging for the new log lines (G004, baseline pruned) and a dict[str, Any] annotation for the jobs query params. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> (cherry picked from commit ab11430)
❌ 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 |
| from metadata.ingestion.ometa.client import RestTransportError # noqa: PLC0415 | ||
|
|
||
| try: | ||
| response = client.get_raw(path, data=data) |
There was a problem hiding this comment.
Artifact downloads lose request metrics
Multi-job downloads now use get_raw, which bypasses the source_api_calls tracking in TrackedREST.get. Catalog, manifest, and test-result downloads disappear from request counts and durations, making slow or rate-limited scans harder to diagnose. Keep the raw response checks, but add tracking for get_raw.
Code Review ✅ Approved 🟡 Medium riskMerging dbt Cloud artifacts across jobs changes ingested model SQL and catalog data; incorrect environment grouping could produce inaccurate metadata. Backports multi-job dbt Cloud artifact ingestion to 2.0, letting users list several job IDs or enable 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 |
Backport of #36596 (Fixes #22769) to
2.0: cherry-picked with-xfromab11430bc4d.Why
On 2.0 the dbt Cloud source reads one run's
manifest.json, and dbt only setscompiled_codeon the nodes that run compiled. A deployment whose ingested job runs a partial selection getsrawSqlbut no compiledsqlon nearly every model. With #36596 the user can list several job IDs (or setdbtCloudIngestAllJobs), and the artifacts are merged per environment so compiled SQL from a full job isn't lost.Conflicts resolved
dbt_config.pyimports: 2.0 still usestyping.Dict/List/Optional/Tuple(# noqa: UP035), soAnywas added to that import instead of main'scollections.abcform; the function-level imports keep 2.0's# noqa: PLC0415.ingestion/.ruff-g004-baseline.jsonand the threeui/src/jsons/ingestionSchemas/*.jsoncopies don't exist on 2.0, so those hunks were dropped.The schema change is additive (
dbtCloudIngestAllJobs, defaultfalse);dbtCloudJobIdstays a string. No migration needed.Tests
On this branch with regenerated Python models:
pytest tests/unit/test_dbt_config_errors.py tests/unit/test_dbt.py: 361 passedruff check/ruff format --checkon the changed Python files: clean🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge, with the existing non-blocking gap in request metrics.Findings
Summary
Adds dbt Cloud ingestion from several jobs, merging their artifacts within each environment while keeping the existing single-run default.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[dbt Cloud configuration] --> B{Several jobs selected?} B -->|No| C[Read one latest completed run] B -->|Yes| D[Find latest completed run for each job] D --> E[Group runs by environment] E --> F[Download and merge one environment] F --> G{Artifacts readable and schemas match?} G -->|Yes| H[Yield merged artifacts] G -->|No| I[Record failed environment] H --> J[Continue with next environment] I --> J J --> K[Report any failed environments]Reviews (2) · Last reviewed commit: "Merge branch '2.0' into backport/2.0-dbt..." · Reviewed by Greptile