Repository navigation
sdkgo: remove the legacy-SDK hint - #8327
Conversation
…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>
…kgo-keep-the-legac Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: parth.bansal <parth.bansal@databricks.com>
|
/review |
There was a problem hiding this comment.
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
Optionsappends a secondclient.WithCredentialsafterConfigOptions(cfg)and relies on sdk-go letting the last one win (options.go:44-46). Nothing in this repo checks that assumption. ShouldOptionsbuild its own option list, or shouldConfigOptionstake the credentials (or themarkLoginErrorsflag) as a parameter, so the overridden entry is never created? (non-blocking)
| } | ||
| return append(ConfigOptions(cfg), | ||
| // Takes the place of ConfigOptions' credentials, so a failed login is a loginError. | ||
| client.WithCredentials(configCredentials{cfg: cfg, markLoginErrors: true}), |
There was a problem hiding this comment.
[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?
There was a problem hiding this comment.
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>
|
On the question about the second |
Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: parth.bansal <parth.bansal@databricks.com>
✅ Integration test reportCommit: f49449b
Top 3 slowest tests (at least 2 minutes):
|
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>
|
This PR now removes |
Changes
Removes
sdkgo.WithLegacyHint, which appendedSet 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: deletesWithLegacyHint, themodularErrortype and thelegacyHintconstant, and the imports only they used. TheDATABRICKS_CLI_GO_SDKselector (EnvVar,UseModular) stays as it is.libs/sdkgo/selector_test.go: deletesTestWithLegacyHintandTestWithLegacyHintOnUndecodableResponse.TestUseModularandTestUseModularUsesDefaultTablestay. The test helpers those tests used (newTestServer,clients,createModular,respond) stay as well, sincetransport_test.gouses 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.goandlibs/sdkgo/options.gomatchmain. No command callsWithLegacyHint, 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, includingTestUseModularandTestUseModularUsesDefaultTable.go build ./...andgo 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 inlibs/sdkgoorlibs/filer.go mod tidyleavesgo.modandgo.sumunchanged.rgfinds no remaining use ofWithLegacyHint,modularError,legacyHintor the hint's text in the repository../task test(the full unit and acceptance suite); CI runs it.Pre-PR review
isaac review --uncommitted --production) gave no findings, and Codex (read-onlycodex execofgit diff HEAD) gaveCODEX_REVIEW: clean. Codex got no factory knowledge-base lessons, since they are internal and this repository is public.This pull request and its description were written by Isaac.