Skip to content

fix: bigquery_v1 global connection import and update-path adapter issues - #721

Open
dbtagarovat wants to merge 2 commits into
mainfrom
fix/709-bigquery-v1-import-use-latest-adapter
Open

fix: bigquery_v1 global connection import and update-path adapter issues#721
dbtagarovat wants to merge 2 commits into
mainfrom
fix/709-bigquery-v1-import-use-latest-adapter

Conversation

@dbtagarovat

@dbtagarovat dbtagarovat commented Aug 3, 2026

Copy link
Copy Markdown

Summary

  • readGeneric (shared by Read and ImportState) never set BigQueryConfig.UseLatestAdapter, so importing (or refreshing) a bigquery_v1 dbtcloud_global_connection left use_latest_adapter = null in state. The ModifyPlan guard then compared that null (false) against the configured true and raised a false "Adapter version cannot be changed on an existing connection" error on a plain no-op plan.
  • Fix: derive UseLatestAdapter from the adapter version returned by the API in readGeneric, mirroring what Create already does explicitly after creating a v1 connection.
  • Also found and fixed a related issue in the same code path: Update unconditionally sent timeout_seconds whenever it differed from state, but timeout_seconds is a bigquery_v0-only field that the API rejects for bigquery_v1. Create already handles this correctly per-adapter; Update now does too.

Verification

Also confirmed live against a real dbt Cloud backend (personal devspace):

  • Built the pre-fix (main) provider, created a bigquery_v1 global connection (use_latest_adapter = true), removed it from state, then ran terraform import on the same connection — reproduced the exact reported error: "Adapter version cannot be changed on an existing connection" on a plan with zero config changes.
  • Rebuilt with this fix, repeated the same remove-and-reimport, then plan — the false error is gone; use_latest_adapter is no longer part of the diff.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./pkg/framework/objects/global_connection/... (acceptance tests skip without TF_ACC, package compiles and unit-level checks pass)
  • Live-tested against a real dbt Cloud backend (see Verification above)

Closes #709

readGeneric (shared by Read and ImportState) never set
BigQueryConfig.UseLatestAdapter, so imported/refreshed bigquery_v1
connections had it null in state. The ModifyPlan guard then compared
that null (false) against the configured true and raised a false
"Adapter version cannot be changed" error on a plain no-op plan.
Derive UseLatestAdapter from the adapter version returned by the API,
mirroring what Create already does after creating a v1 connection.

Also guard sending timeout_seconds on Update: it's a bigquery_v0-only
field and the API rejects it for bigquery_v1, but Update was sending
it unconditionally whenever it differed from state.

Closes #709
@dbtagarovat
dbtagarovat requested a review from a team as a code owner August 3, 2026 10:33

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

Thank you! :shipit:

…709

- readGeneric now derives use_latest_adapter from the API's adapter
  version for both bigquery_v1 (true) and bigquery_v0 (false), instead
  of leaving it null.
- ModifyPlan no longer false-positives "Adapter version cannot be
  changed" on a no-op plan once state correctly reflects
  use_latest_adapter, while still blocking a genuine v0<->v1 change.
- Update no longer sends timeout_seconds to the API for bigquery_v1
  connections (verified via the actual PATCH request body against a
  mock server), while still sending it for bigquery_v0.

All four failure-mode tests verified to fail against the pre-fix code
and pass with the fix applied.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import gap: use_latest_adapter is not set for imported bigquery_v1 connections, causing adapter-change errors and compounding timeout_seconds bug

2 participants