fix: clear error when Bytebase server predates 3.17.0#192
Open
fix: clear error when Bytebase server predates 3.17.0#192
Conversation
Bytebase 3.16.x servers emit a bare UUID in the actuator `workspace` field; since 3.17.0 the provider no longer prepends `workspaces/` to that value, so the bare UUID was forwarded as the IAM policy resource and the server rejected it with a cryptic `invalid workspace resource "<uuid>"` error. Fail fast at client init with an explicit version-mismatch message instead, matching how other Terraform providers handle backend version skew. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
d-bytebase
approved these changes
Apr 20, 2026
Drop the trailing period and restructure the multi-sentence error into a single sentence so the string no longer ends with punctuation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ecmadao
reviewed
Apr 21, 2026
| if workspace == "" { | ||
| return nil, errors.New("actuator returned empty workspace name; cannot initialize provider") | ||
| } | ||
| if !strings.HasPrefix(workspace, "workspaces/") { |
Collaborator
There was a problem hiding this comment.
Before 3.17.0 we only have the workspace ID in the actuator https://github.com/bytebase/bytebase/blob/release/3.16.1/backend/api/v1/actuator_service.go#L151, so it will never trigger this error, always return in line112
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
workspacevalue, instead of letting a cryptic server-side error surface later.Why
Bytebase 3.16.x servers populate the actuator
workspacefield with a bare UUID (the proto field was namedworkspace_idat the time). Starting in 3.17.0, the provider no longer prependsworkspaces/to that value (it expects the server to return the fully-qualifiedworkspaces/{id}). On a 3.16.x server, the bare UUID is forwarded as the IAM policyresourcefield, and the server'svalidateWorkspaceResourcecheck rejects it with:…which gives the user no hint that the real answer is "upgrade the Bytebase server." Other Terraform providers (hashicorp/kubernetes, aws, google, vault) handle backend version skew by failing fast at client init with a clear message; this PR applies the same pattern.
The fix
In
client.NewClient, after fetching actuator info:Test plan
No unit tests added —
client/has no test scaffolding today and standing it up for one branch is disproportionate to the change. Verified manually:terraform planon abytebase_iam_policyresource → fails at provider init with the new message (not at IAM call site with the cryptic error).terraform plansucceeds unchanged.go vet ./...,gofmt,go build ./...all clean locally.