Skip to content

Fixes #22769: Ingest dbt Cloud artifacts from multiple jobs - #36596

Merged
harshsoni2024 merged 10 commits into
mainfrom
ulixius9/dbt-pipeline-missing-job-id
Nov 5, 2026
Merged

harshsoni2024 merged 10 commits into
mainfrom
ulixius9/dbt-pipeline-missing-job-id

Conversation

@ulixius9

@ulixius9 ulixius9 commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #22769

The dbt Cloud artifact source (dbtConfigType: cloud) could only read one run: the given job's latest, or with no job ID, the latest completed run of any job in the account. Projects that split models across jobs could ingest only one of them, and an empty Job ID picked an arbitrary job each run.

This PR:

  • dbtCloudJobId accepts comma-separated job IDs (553344,553345). It stays a string, so stored pipelines need no migration.
  • Adds an opt-in dbtCloudIngestAllJobs flag (default false). It reads every job of the project, or of the account when no project is set, and skips CI jobs, which build into temporary PR schemas. Job IDs take precedence over it.
  • Existing behaviour is unchanged: with no job IDs and the flag off, the single latest run is read, with the same error messages. There are two small differences. A 429 is now retried instead of failing straight away, and a missing catalog always logs a warning.

How multiple jobs are combined. Every job's manifest.json lists the whole project, but dbt only sets compiled_code on the nodes that run compiled, and only a docs generate job has a catalog. Feeding the jobs to the source one after another would let a partial job (dbt run -s tag:hourly) overwrite every model's data model written by a full job, with no SQL and no catalog columns. Instead:

  • The artifacts are merged into one set per dbt Cloud environment. Different environments build different schemas, so they are never merged.
  • The newest run's manifest decides which nodes exist and how they are configured. Older runs only fill in the compiled fields of nodes the newest run didn't compile. A model removed since an older run doesn't come back.
  • Catalog entries are unioned, newest first. The run_results files are concatenated, and the source already keeps the newest result per test.
  • Only a job with no completed run is skipped. Auth errors and failures listing runs fail the run at once. Any other failure on a job leaves that job's whole environment un-ingested: an exhausted retry, a manifest, catalog or run_results response other than a 404, or mismatched dbt versions. Merging without that job would blank the models only it compiled. The other environments are still ingested, and the run then fails, naming the skipped environments, so one abandoned broken job doesn't block the whole account. In merge mode, artifacts are fetched with get_raw, so that only a 404 reads as "absent".
  • The run fails, naming both jobs, when two jobs in one environment wrote different manifest schema versions, which happens with a job-level dbt version override. One manifest schema can't validate the other's nodes.
  • Runs are listed first, then one environment at a time is downloaded, merged and yielded, so memory holds one merged manifest.

Decision record: docs/decisions/2026-10-29-dbt-cloud-multi-job-artifacts-merge-per-environment.md.

Type of change:

  • New feature

High-level design:

  • Schema (openmetadata-spec/.../dbtconfig/dbtCloudConfig.json): dbtCloudJobId description updated, and a new optional dbtCloudIngestAllJobs: boolean = false. The UI form is rendered from the schema (RJSF). The three generated UI schema copies were regenerated with parse-schema, and no hand-written UI or Java code reads these fields.
  • dbt_config.py, the dbt Cloud handler:
    • parse and de-duplicate the job IDs;
    • with the flag and no IDs, list jobs through /accounts/{id}/jobs/ (paginated, CI skipped);
    • one job → _get_dbt_cloud_latest_run + _get_dbt_cloud_run_files, the old path unchanged;
    • several → _get_dbt_cloud_merged_files: latest run per job, grouped by environment_id, sorted newest first, fetched strictly, checked for the same schema version, then _merge_dbt_files.
    • The error classification for list endpoints moved into _dbt_cloud_get, so the jobs list and the runs list report errors the same way.
    • The client now treats 429 as retryable (retry_codes=[429, 503, 504], limit_codes=[]), because an all-jobs scan makes one runs call per job.
  • Alternatives rejected:
    • Making "all jobs" the empty-Job-ID default: rejected because it changes existing pipelines.
    • Yielding one DbtFiles per job: rejected because a partial job blanks SQL and catalog columns, and the project gets re-processed N times.
    • Splitting manifests with mismatched versions into separate groups: rejected because that brings the overwrite back.
  • Rollout: backward compatible, with no migration. A follow-up is needed in Collate: its own copy of Database/workflows/dbt.md takes precedence over this one, so it needs the same help-text update.

Tests:

Use cases covered

  • No job ID and the flag off: one /runs call, no /jobs/ call. A real DbtCloudConfig built without the flag behaves the same way.
  • Comma-separated IDs, with whitespace, trailing commas and duplicates.
  • All-jobs mode reads every page of /jobs/, skips CI jobs and passes project_id. Job IDs take precedence over the flag.
  • A partial job does not blank models a full job compiled, in both job orders.
  • The newest manifest decides nodes and config: a stale renamed model and an old alias don't come back.
  • The newest run wins when two jobs compiled the same model. Catalogs are unioned, first entry wins.
  • Different environments stay apart, and one environment is yielded before the next is downloaded.
  • A job with no completed run is skipped. Each of these fails the run:
    • an unusable runs response;
    • a missing manifest, with job and run named;
    • a catalog that runs out of 429 retries;
    • a run_results request that runs out of 503 retries;
    • an auth error, which fails on the first request.
  • No job with a completed run → error. Mismatched manifest schema versions in one environment → error naming both jobs.
  • A 429 is retried through the real REST client, with only requests.Session.request and time.sleep patched.
  • The default path keeps its "Manifest file not found in dbt Cloud…" message.

Unit tests

  • I added unit tests for the new/changed logic.
  • File: ingestion/tests/unit/test_dbt_config_errors.py. 46 passed, with 28 new cases in TestDbtCloudMultipleJobs and TestDbtCloudRateLimit, plus updates to TestDbtCloudErrorClassification.
  • Mutation-checked: reverting each guard turns at least one test red. The guards checked were the compiled-fill, the newest-authoritative merge, the recency sort, strict mode, the environment split, the version guard, skipping only no-run jobs, the 429 config, ID de-duplication, the catalog union and the CI filter.
  • Command: python -m pytest tests/unit/test_dbt.py -k "not DbtUnitTest" tests/unit/test_dbt_config_errors.py tests/unit/test_dbt_http_config.py tests/unit/utils/test_gcs_client_impersonation.py tests/unit/test_dbt_ingest.py tests/unit/test_dbt_test_definition.py tests/unit/test_dbt_test_descriptions.py tests/unit/test_workflow_parse.py → 242 passed, 119 deselected. These are every unit test file that imports dbt_config, plus the other dbt test files.
  • Not run locally: test_dbt.py::DbtUnitTest (119 tests). In this environment it stalls at test_dbt_raw_query, and it stalls in the same place with origin/main's dbt_config.py, so the cause is the local environment, not this change. None of it uses the dbt Cloud handler. CI runs it.
  • Coverage: the only uncovered lines in the dbt Cloud code are the generic fallback branches that predate this PR: the unexpected-exception wrapper, non-401/404 APIError, and the non-strict run_results except.
  • ruff format / ruff check clean.

Backend integration tests

  • Not applicable (no backend API changes). The schema change adds one optional field to an ingestion-only config, and no Java code reads it.

make java_affected selects no Java unit tests and 26 integration tests (<- area ingestion-pipelines / smoke) because of the schema touch. No Java code reads the new optional field; the only Java change is the generated DbtCloudConfig POJO.

Local Java test run: 2 flaky failures, both unrelated (commit ebf187d8aab, before the rebase onto main; JDK 21, mysql-elasticsearch)

Step Scope Classes Tests Failed Skipped Result
integration parallel lane 25 1399 1 95 WorkflowRedeploySignalIT#suspendedWorkflowRedeployedTakesNoSignal: a flake under parallel load; passes 2/2 when re-run alone
integration isolated lane 1 131 1 0 WorkflowDefinitionResourceIT#test_dataProductPortCannotBecomeBothKindsThroughOneRequest: a known approval flake, fixed on main by #36560 after this branch was cut. The branch has since been rebased onto main to pick that fix up

Both are governance-workflow tests that this change can't reach. Per-class details are in this comment. The suite was not re-run after the rebase; the merge queue runs it in full.

Ingestion integration tests

  • Not applicable: there are no dbt Cloud tests under ingestion/tests/integration/, and the change is covered at the HTTP-client boundary.

Playwright (UI) tests

  • Not applicable. The only UI changes are generated schema JSON and help text; the new boolean is rendered by the existing schema-driven form.

Manual testing performed

Ran the fetcher (get_dbt_details, this branch's code) against a real dbt Cloud account on a *.us1.dbt.com cell host: 1 project-less scan, about 15 jobs across 6 environments, dbt 2025.11 → 2026.10.

  1. No job IDs, flag off (old behaviour): it picked the newest run of any job. That was a jaffle_shop run with 0 of 5 models compiled, no catalog, no test results, so ingesting it would write every model with no SQL. This is the problem the issue describes.
  2. Ingest From All Jobs:
    • CI jobs were not read, and 3 jobs with no completed run were skipped with a warning.
    • For the same jaffle_shop environment, the merge produced 5/5 models compiled, a catalog of 8 nodes and 225 test results from 18 run_results files.
    • 4 more environments were ingested as one artifact set each.
  3. A real broken job: an ad-hoc job, last run March 2026, fails at dbt seed and never writes a manifest.
    • The first version of this PR failed the whole scan on it.
    • It now leaves only that environment out and fails the run with dbt artifacts of 1 dbt Cloud environment(s) were not ingested: [70471823526777] Manifest file not found in dbt Cloud for run [70471869382033] of job [70471823571802].
    • On this account that environment happens to come last. test_a_broken_job_skips_only_its_environment_then_fails_the_run covers a broken environment in the middle.
  4. Selected jobs, on the same account. Environment 70471823472765 has a full job (70471823495457: seed/run/test + docs, latest run today) and a partial job (70471823538804: dbt run --select customers).
    • Partial job alone: 1 of 5 models compiled.
    • Full job alone: its latest run errored early, so 0 of 5 compiled, with no catalog and no results. A single-job ingestion of this run would blank every model's SQL.
    • Both together ("70471823538804,70471823495457"): one merged set. The newest manifest decides the nodes, and customers keeps its SQL from the partial job, so 1 of 5 compiled plus its test result.
    • Two jobs in different environments: two separate sets, one of them 5/5 compiled with 43 results.
    • " 70471823495457, 70471823495457 ,": de-duplicated to the single-job path.
  5. Full metadata ingest into a local OpenMetadata server (2.0.0-SNAPSHOT). I created a Redshift service with the 8 jaffle_shop tables in dev.dbt_production, then ran three dbt workflows (dbtConfigType: cloud) in order:
Workflow Models with SQL dbt tests (with results) Result
Default (no job IDs) 0 / 5: it picked today's errored run 0 100%, but every model has an empty SQL tab
11 job IDs of the jaffle_shop environment (merged) 5 / 5 28 (25) 100%; 91 records, the project processed once rather than 11 times
Ingest From All Jobs (24 jobs) 5 / 5, unchanged 28 (25) 99.17%; 3 jobs with no run skipped, and the broken environment 70471823526777 reported as DBT Configuration Error … 1 dbt Cloud environment(s) were not ingested while every other environment was ingested

Lineage (upstream edges) matched in all three. The remaining warnings come from this test instance: a missing openmetadata owner, and dbt tags and custom properties that don't exist there.
Open question: a second environment on this account also builds into dev.dbt_production. In all-jobs mode it was ingested after jaffle_shop and added two column descriptions; nothing was lost here. Environments are ingested separately, though, so two environments targeting the same schema both write to the same tables, and the later one wins.

UI screen recording:

Not applicable: this is not a UI feature. The only UI changes are a new boolean field rendered automatically from the JSON schema, and help text.

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: no migration needed. The new field is optional with a false default, and dbtCloudJobId keeps its type.

  • For a UI feature or feature task: not applicable (see above).

  • 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 SHA a98c6a8 (six passes). Every 🔴 from earlier passes is fixed in this branch: per-job overwrite → per-environment merge; silent per-job skips → skip only no-run jobs, plus strict artifact fetch; mixed dbt versions → explicit failure; stale nodes from old runs → the newest manifest is authoritative. Answered rather than changed: Collate's own dbt.md copy needs the same help text (separate repo, follow-up). _compiled_query reads raw manifest dicts before parsing, so dbt_utils.get_dbt_compiled_query, which reads parsed node objects, can't be reused.

  • Decision check: adds docs/decisions/2026-10-29-dbt-cloud-multi-job-artifacts-merge-per-environment.md.

  • The issue properly describes why the new feature is needed.

  • I have updated the documentation (in-app help Database/workflows/dbt.md).

  • I have added tests around the new logic.

🤖 Generated with Claude Code

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

Copy link
Copy Markdown
Member Author

Local Java test run: FAILED — details

  • Commit: ebf187d8aabf (base origin/main)
  • The summary is in the PR description.

Failed: WorkflowRedeploySignalIT#suspendedWorkflowRedeployedTakesNoSignal(TestNamespace)

Tests run locally

  • integration · mysql-elasticsearch · parallel: BaseEntityIT$ListEntityHistoryByTimestampPaginationTest (115 passed, 1 skipped), ConfigResourceIT (13 passed), DatabaseSmokeIT (9 passed), GlossaryTermResourceIT (280 passed, 29 skipped), IngestionPipelineAgentTypeIT (7 passed), IngestionPipelineLogStreamIT (18 passed), IngestionPipelineLogStreamingResourceIT (6 passed), IngestionPipelineOwnerInheritanceIT (17 passed), IngestionPipelineProgressStreamIT (2 passed), IngestionPipelineResourceIT (6 passed), IngestionPipelineSortIT (8 passed), K8sEnvVarSerializationIT (7 passed), K8sOMJobOperatorIT (97 passed, 18 skipped), K8sPipelineEnvVarIT (4 passed), OrphanIngestionPipelineCleanupIT (10 passed), PipelineStatusAuthorizationIT (10 passed, 2 skipped), RunIngestionPipelineForEntityIT (300 passed, 28 skipped), SeedDataPresenceIT (2 passed), TableResourceIT (139 passed), TestConnectionDefinitionResourceIT (8 passed), UserResourceIT (102 passed, 5 skipped), WorkflowRedeploySignalIT (1 passed, 1 failed), WorkflowResourceIT (15 passed), WorkflowSignalDeliveryIT (1 passed), WorkflowTaskAssigneesIT (13 passed), WorkflowTriggerPermissionsIT (12 passed, 3 skipped)

Per-class counts come from the test reports, which can credit a test to the wrong class when classes run concurrently, and keep only the last run of a nested class that several test classes inherit. The summary's step totals are Maven's own counts.

Why these tests
  • area ingestion-pipelines ← openmetadata-spec/src/main/resources/json/schema/metadataIngestion/dbtconfig/dbtCloudConfig.json
  • smoke ← code other than a test class changed
Commands
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=ConfigResourceIT,DatabaseSmokeIT,GlossaryTermResourceIT,IngestionPipelineAgentTypeIT,IngestionPipelineLogStreamIT,IngestionPipelineLogStreamingResourceIT,IngestionPipelineOwnerInheritanceIT,IngestionPipelineProgressStreamIT,IngestionPipelineResourceIT,IngestionPipelineSortIT,K8sEnvVarSerializationIT,K8sOMJobOperatorIT,K8sPipelineEnvVarIT,OrphanIngestionPipelineCleanupIT,PipelineStatusAuthorizationIT,RunIngestionPipelineForEntityIT,SeedDataPresenceIT,TableResourceIT,TestConnectionDefinitionResourceIT,UserResourceIT,WorkflowRedeploySignalIT,WorkflowResourceIT,WorkflowSignalDeliveryIT,WorkflowTaskAssigneesIT,WorkflowTriggerPermissionsIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state -Dit.test=WorkflowDefinitionResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false

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.
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.
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.
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.
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.
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.
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.
@ulixius9
ulixius9 force-pushed the ulixius9/dbt-pipeline-missing-job-id branch from ebf187d to a54a106 Compare October 30, 2026 11:03
@ulixius9
ulixius9 marked this pull request as ready for review October 30, 2026 11:04
@ulixius9
ulixius9 requested a review from a team as a code owner October 30, 2026 11:04
@ulixius9
ulixius9 requested review from Khairajani and a balanced review from Copilot October 30, 2026 11:04

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 insufficient remaining quota.

@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

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.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Generated Sources Auto-Updated

The generated TypeScript types (src/generated/) and dereferenced JSON
schemas (src/jsons/, public/jsons/) have been automatically updated
based on JSON schema changes in this PR.

Copilot AI balanced review requested due to automatic review settings October 30, 2026 11:11

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 insufficient remaining quota.

@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.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 80%
80.5% (134797/167435) 67.35% (48206/71569) 70.39% (27145/38562)

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.
Copilot AI balanced review requested due to automatic review settings November 2, 2026 12:53

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 insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 3 closed / 3 findings

🟡 Medium risk · Combining multiple dbt Cloud job artifacts per environment could yield incorrect model SQL, catalog columns, or test results in ingested metadata.

Adds multi-job dbt Cloud artifact ingestion: dbtCloudJobId accepts comma-separated IDs, and a new opt-in dbtCloudIngestAllJobs flag reads every non-CI job. Artifacts are merged per environment with the newest run's manifest deciding nodes, and broken environments are skipped and named in the final failure. Two resolved findings: the committed TypeScript types were regenerated, and the artifact 401/403 behaviour was kept with the ADR narrowed to match. No open findings.

✅ 3 closed
✅ Quality: Committed TS types not regenerated for new dbtCloudConfig schema

📄 openmetadata-spec/src/main/resources/json/schema/metadataIngestion/dbtconfig/dbtCloudConfig.json:31-41
The PR adds dbtCloudIngestAllJobs to dbtCloudConfig.json and rewrites the dbtCloudJobId description. The committed generated TypeScript was not updated: openmetadata-ui/src/main/resources/ui/src/generated/metadataIngestion/dbtconfig/dbtCloudConfig.ts still reads dbt cloud job id. and has no dbtCloudIngestAllJobs. The same applies to dbtPipeline.ts, workflow.ts, ingestionPipeline.ts, createIngestionPipeline.ts and serviceProgressEvent.ts. Under the repo's schema-first rule these files are committed and checked by the typescript-type-generation workflow, so they are now stale, and any UI code that reads the new flag won't type-check. To fix, run the TS type generation from the updated schema and commit the regenerated files under ui/src/generated/**. Don't edit them by hand.

✅ Bug: Transport/JSON errors on artifacts abort all environments, not just one

📄 ingestion/src/metadata/ingestion/source/database/dbt/dbt_config.py:396-401 📄 ingestion/src/metadata/ingestion/source/database/dbt/dbt_config.py:553-563 📄 docs/decisions/2026-10-29-dbt-cloud-multi-job-artifacts-merge-per-environment.md:33-38
The new per-environment guard only catches DBTConfigException. _get_dbt_cloud_artifact calls client.get_raw(...), and that call raises RestTransportError when connections, timeouts or retries run out (ometa/client.py re-raises for raw callers). response.json() can also raise JSONDecodeError when a proxy returns a 200 with an HTML body. Neither error is a DBTConfigException, so it skips the except at L398, ends the generator, and gets wrapped by the outer handler at L280. The environments after it are then never ingested. The ADR lists "an exhausted retry" as a failure that should skip only that environment, and a timeout while downloading a large manifest is exactly that case. Fix: catch these errors inside the environment loop, or convert them to DBTConfigException in _get_dbt_cloud_artifact.

✅ Quality: Artifact 401/403 skips the environment, but the ADR says auth fails at once

📄 ingestion/src/metadata/ingestion/source/database/dbt/dbt_config.py:398-401 📄 ingestion/src/metadata/ingestion/source/database/dbt/dbt_config.py:559-562 📄 docs/decisions/2026-10-29-dbt-cloud-multi-job-artifacts-merge-per-environment.md:33-34
The updated ADR says "Auth errors and failures listing runs fail the run at once". When an artifact download returns 401 or 403, though, _get_dbt_cloud_artifact raises a generic DBTConfigException("dbt Cloud answered 403 ..."). The new except DBTConfigException at L398 catches it, skips that environment and moves on to the next. For example, a token that can list runs but lacks permission on one project's artifacts is handled as a per-environment skip, not an immediate auth failure, and the error message does not say it is a token problem. Fix: either raise 401/403 artifact responses as a dedicated auth exception that the environment loop re-raises, or change the ADR sentence so it covers only auth errors from listing runs.

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

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

@ulixius9 ulixius9 added the 2.1 label Nov 4, 2026
@ulixius9
ulixius9 enabled auto-merge (squash) November 5, 2026 09:34
@harshsoni2024
harshsoni2024 merged commit ab11430 into main Nov 5, 2026
123 of 126 checks passed
@harshsoni2024
harshsoni2024 deleted the ulixius9/dbt-pipeline-missing-job-id branch November 5, 2026 09:35
ulixius9 added a commit that referenced this pull request Nov 20, 2026
…37987)

* 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.

---------


(cherry picked from commit ab11430)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Himanshu Khairajani <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.1 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.

Ingestion for multiple job id's with dbt cloud

3 participants