Skip to content

sdkgo: remove the legacy-SDK hint - #8327

Merged
parthban-db merged 14 commits into
mainfrom
factory-1639-sdkgo-keep-the-legac
Dec 3, 2026
Merged

parthban-db merged 14 commits into
mainfrom
factory-1639-sdkgo-keep-the-legac

Conversation

@parthban-db

@parthban-db parthban-db commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Removes sdkgo.WithLegacyHint, which appended Set DATABRICKS_CLI_GO_SDK=legacy to use the previous Go SDK, and report the issue at https://github.com/databricks/cli/issues. to modular-SDK errors.

  • libs/sdkgo/selector.go: deletes WithLegacyHint, the modularError type and the legacyHint constant, and the imports only they used. The DATABRICKS_CLI_GO_SDK selector (EnvVar, UseModular) stays as it is.
  • libs/sdkgo/selector_test.go: deletes TestWithLegacyHint and TestWithLegacyHintOnUndecodableResponse. TestUseModular and TestUseModularUsesDefaultTable stay. The test helpers those tests used (newTestServer, clients, createModular, respond) stay as well, since transport_test.go uses them.

Why

The hint tells users to switch back to the legacy Go SDK, and that causes more problems than it solves. It also reached errors that switching SDKs can't fix, such as a failed login, since both Go SDKs share the CLI's credentials. This PR started as a fix that kept the hint off login failures; the owner decided to remove the hint instead, so that fix is gone and libs/sdkgo/credentials.go and libs/sdkgo/options.go match main. No command calls WithLegacyHint, so no command's behavior changes and no changelog fragment is needed.

Tests

  • env -u DATABRICKS_WORKSPACE_ID go test ./libs/sdkgo/... ./libs/filer/... -count=1: passes, including TestUseModular and TestUseModularUsesDefaultTable.
  • go build ./... and go vet ./libs/sdkgo/: pass.
  • go tool -modfile=tools/go.mod golangci-lint run ./libs/sdkgo/...: 0 issues.
  • go tool -modfile=tools/go.mod deadcode -test ./...: reports nothing in libs/sdkgo or libs/filer.
  • go mod tidy leaves go.mod and go.sum unchanged.
  • rg finds no remaining use of WithLegacyHint, modularError, legacyHint or the hint's text in the repository.
  • I did not run ./task test (the full unit and acceptance suite); CI runs it.

Pre-PR review

  • Rounds: 1 of 3, run on this PR's first version, which kept the hint off login failures. Isaac (isaac review --uncommitted --production) gave no findings, and Codex (read-only codex exec of git diff HEAD) gave CODEX_REVIEW: clean. Codex got no factory knowledge-base lessons, since they are internal and this repository is public.
  • No pre-PR review saw the removal in this version, which replaced that change after the PR existed.
  • No correctness or completeness findings are open.

This pull request and its description were written by Isaac.

parthban-db and others added 8 commits December 1, 2026 16:31
…ector

libs/sdkgo turns the CLI's resolved classic config into sdk-go client
options. Options sends each sdk-go request through a classic API client
built from the config, so it gets the classic retries, timeouts, rate
limit, User-Agent segments and debug logs. The files client now takes
only ConfigOptions (routing and auth), with no change in behavior.

UseModular reads DATABRICKS_CLI_GO_SDK (unset, classic or modular)
through libs/env, with an empty per-group default table, and
WithClassicHint adds a hint to internal errors of the modular path.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: parth.bansal <parth.bansal@databricks.com>
…ll deadline

With debug_headers on, the classic client logs the Authorization header
unmasked. The modular path masks it in its debug log until the owner
decides whether to match classic. Tests now check the W3C format of the
traceparent both paths send, and that neither path puts a deadline on a
call, since Options turns off sdk-go's 5-minute call timeout.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: parth.bansal <parth.bansal@databricks.com>
DATABRICKS_CLI_GO_SDK now takes legacy and modular, and WithClassicHint
is WithLegacyHint, at the owner's request.

Fixes from a Codex review of the whole PR:
- A request to a host other than the config's skipped the classic
  client's timeout while sdk-go's call timeout is off, so a server that
  never answered could hang it. It now waits for the response header no
  longer than the classic per-request timeout.
- A login failure from the credentials bridge got the hint to switch
  SDKs, though both SDKs share the credentials. The bridge marks its
  errors, which WithLegacyHint leaves as is.
- The test server indexed an empty handler list for a request outside
  the endpoint under test, such as a port watcher's probe, and panicked
  while holding its lock.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: parth.bansal <parth.bansal@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: parth.bansal <parth.bansal@databricks.com>
The auth bridge that the files client uses returns config.Authenticate's
error unchanged again, as it did in libs/filer. Only the clients that
Options builds mark a failed login, so that WithLegacyHint doesn't add
its hint to it.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: parth.bansal <parth.bansal@databricks.com>
Keeping WithLegacyHint's hint off login failures needed a credentials
wrapper, an error type and a second options helper, though no command
calls WithLegacyHint yet. That moves to its own PR. ConfigOptions,
Options and the auth bridge are back to the first commit's code.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: parth.bansal <parth.bansal@databricks.com>
Both Go SDKs share the CLI's credentials, so switching SDKs can't fix a
failed login, such as a cached token without a refresh token. The
credentials of the clients that Options builds now return such a failure
as a loginError, which keeps the message and unwraps to the original
error, and WithLegacyHint returns it as is. ConfigOptions, which the files
client uses, keeps the credentials unchanged, so the files client's
errors stay exactly as they were.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: parth.bansal <parth.bansal@databricks.com>
@parthban-db
parthban-db marked this pull request as ready for review December 2, 2026 18:08
@parthban-db
parthban-db requested review from a team as code owners December 2, 2026 18:08
…kgo-keep-the-legac

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: parth.bansal <parth.bansal@databricks.com>
@parthban-db

Copy link
Copy Markdown
Contributor Author

/review

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review at 83a9413. Each finding was verified against the code.

No blocking issues found. 1 non-blocking comment(s) and 1 question(s) below.

This PR marks a failed login in a client built with sdkgo.Options as a loginError, so that WithLegacyHint returns it without the "Set DATABRICKS_CLI_GO_SDK=legacy" hint. ConfigOptions and the files client keep their current behavior. The error paths look correct. A login failure before the first attempt comes back as a loginError, and a failure inside the classic transport comes back wrapped in *url.Error, which already skips the hint. The only fix I'd ask for is the Options doc comment. I've also left an open question on how the credential override is wired.

Questions

  1. Options appends a second client.WithCredentials after ConfigOptions(cfg) and relies on sdk-go letting the last one win (options.go:44-46). Nothing in this repo checks that assumption. Should Options build its own option list, or should ConfigOptions take the credentials (or the markLoginErrors flag) as a parameter, so the overridden entry is never created? (non-blocking)

Comment thread libs/sdkgo/options.go Outdated
}
return append(ConfigOptions(cfg),
// Takes the place of ConfigOptions' credentials, so a failed login is a loginError.
client.WithCredentials(configCredentials{cfg: cfg, markLoginErrors: true}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nit] The doc comment on Options (line 35) still says it returns "ConfigOptions plus an HTTP client…", but it now also replaces the credentials from ConfigOptions. That replacement works only because sdk-go keeps the last WithCredentials it gets. If someone reorders this append, login failures quietly get the hint again. Can the doc comment say that Options swaps in credentials that turn a failed login into a loginError, and that this relies on the last option winning?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 8ee2de5. The doc comment on Options now says that its credentials return a failed login as a loginError, which WithLegacyHint returns as is. The comment on the WithCredentials line says that sdk-go keeps the last WithCredentials, so the line must stay after ConfigOptions(cfg). TestWithLegacyHintKeepsLoginErrorsOfOptions fails if a reorder drops the override: I checked by removing the line.

…Options

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: parth.bansal <parth.bansal@databricks.com>
@parthban-db

Copy link
Copy Markdown
Contributor Author

On the question about the second client.WithCredentials in Options: I kept the override because the owner asked for the smallest change that leaves ConfigOptions and the files client exactly as they are. The two alternatives are building a separate option list in Options, or adding a credentials or flag parameter to ConfigOptions or a configOptions helper. The earlier version of this fix in #8271 took the helper route, and the owner found it too large. The assumption is tested in this repo: files.NewClient applies its options in order, and TestWithLegacyHintKeepsLoginErrorsOfOptions fails if the override stops winning. I checked this by removing the line. TestConfigOptionsReturnLoginErrorsUnchanged fails if ConfigOptions starts marking errors. The comment at the line now states the ordering requirement (8ee2de5).

Base automatically changed from factory-1489-add-a-modular-go-sdk to main December 2, 2026 18:49
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: parth.bansal <parth.bansal@databricks.com>
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: f49449b

Run: 46979860164

Env ✅​pass 🙈​skip Time
✅​ aws linux-2core-8gb 61 6 1:47
✅​ aws-windows-latest-4core-16gb 61 6 3:06
✅​ azure linux-2core-8gb 61 6 1:44
✅​ azure-windows-latest-4core-16gb 61 6 2:48
✅​ gcp linux-2core-8gb 61 6 1:45
✅​ gcp-windows-latest-4core-16gb 61 6 3:16
Top 3 slowest tests (at least 2 minutes):
duration env testname
3:14 gcp-windows-latest-4core-16gb TestAccept
3:05 aws-windows-latest-4core-16gb TestAccept
2:46 azure-windows-latest-4core-16gb TestAccept

parthban-db and others added 3 commits December 2, 2026 18:59
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: parth.bansal <parth.bansal@databricks.com>
WithLegacyHint added "Set DATABRICKS_CLI_GO_SDK=legacy to use the previous
Go SDK, and report the issue at https://github.com/databricks/cli/issues."
to modular-SDK errors. The owner wants it gone, since telling a user to
switch SDKs causes more problems than it solves: it also reached errors
that switching can't fix, such as a failed login. Nothing calls it yet.

This removes WithLegacyHint, modularError and legacyHint with their tests,
and drops the change that kept the hint off login failures, so
credentials.go and options.go match main again.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: parth.bansal <parth.bansal@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: parth.bansal <parth.bansal@databricks.com>
@parthban-db parthban-db changed the title sdkgo: keep the legacy-SDK hint off login failures sdkgo: remove the legacy-SDK hint Dec 2, 2026
@parthban-db

Copy link
Copy Markdown
Contributor Author

This PR now removes WithLegacyHint entirely instead of keeping its hint off login failures, so libs/sdkgo/options.go and libs/sdkgo/credentials.go match main again. The review thread on options.go and my earlier reply about the second WithCredentials no longer apply.

@parthban-db
parthban-db added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit e8ecc5a Dec 3, 2026
27 checks passed
@parthban-db
parthban-db deleted the factory-1639-sdkgo-keep-the-legac branch December 3, 2026 11:52
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.

3 participants