fix(#2748): stop projecting double-/v1 adapter base_url for workspace_override BYOK #2754
Reference in New Issue
Block a user
Delete Branch "fix/2748-adapter-base-double-v1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Root cause (#2748 engine LLM outage)
#2735 added a
DeriveProvider-from-effective-model fallback inworkspace-server/internal/handlers/workspace_provision.go(~L1195) that, forworkspace_overrideBYOK engines on the claude-code runtime, projects the registryBaseURLAnthropicintoenvVars["ANTHROPIC_BASE_URL"]when absent.The registry
base_url_anthropicis proxy-shaped and carries a trailing/v1(providers.yaml follows the routing layer; see the minimaxPR-5reconciliation comment). The claude-code Anthropic SDK appends/v1/messagestoANTHROPIC_BASE_URLitself. Projecting the proxy value verbatim therefore yields a double/v1-> upstream 404, surfaced to users as "selected model may not exist or no access". This took both coding engines down.Empirical proof (ground-truth endpoint shapes)
https://api.minimax.io/anthropic.../anthropic/v1/messageshttps://api.minimax.io/anthropic/v1.../anthropic/v1/v1/messageshttps://api.kimi.com/coding.../coding/v1/messageshttps://api.kimi.com/coding/v1.../coding/v1/v1/messagesFix
Normalize only at the adapter injection site --
strings.TrimSuffix(strings.TrimRight(base, "/"), "/v1")-- so the SDK re-append produces exactly one/v1. Correct for every anthropic-proto provider (minimax/kimi-coding/anthropic/moonshot).The shared registry value is deliberately left untouched. The only molecule-core reader of
Provider.BaseURLAnthropicother than this adapter site is the LLM proxy resolution, whose/v1-shaped expectation is pinned byTestResolveUpstream_ResolvesToProviderEntry(the proxy dials.../anthropic/v1directly). Changing the registry value would break the proxy.Tests
TestApplyPlatformManagedLLMEnv_AdapterBaseHasNoDoubleV1(MiniMax-M3, kimi-for-coding, plain anthropic) asserting the normalized base AND the proven-correct effective.../v1/messagesURL..../anthropic/v1expectation:TestApplyPlatformManagedLLMEnv_BYOKMiniMaxWorkspaceOverrideProjectsCredsandTestApplyPlatformManagedLLMEnv_BYOKMiniMaxProjectsAnthropicAdapterCreds.go build ./...,go vet, andgo test ./internal/handlers/ ./internal/providers/...all green. Registry regeneration (go run ./cmd/gen-providers) produces zero diff -- no gen drift at HEAD.Refs #2748, #2735.
5-axis review PASS on head
2756415ddf. Correctness: the direct-BYOK claude-code adapter projection now trims trailing slashes and a single trailing /v1 from provider.BaseURLAnthropic before setting ANTHROPIC_BASE_URL, so the SDK appends exactly /v1/messages for MiniMax, Kimi coding, and Anthropic-native bases; pre-set operator/workspace ANTHROPIC_BASE_URL remains respected. Scope: change is constrained to the BYOK/runtimeUsesAnthropicNativeProxy projection path; platform-managed proxy routing is below the early return and unchanged. Tests: existing MiniMax projection assertions were corrected and the new table covers minimax, kimi-for-coding, and anthropic effective messages URLs. Security: no new credential exposure or widened auth path; only URL normalization of an existing provider registry value. CI: required contexts are green on this head, and the Local Provision real-image MiniMax lane also passed. Local Go tests could not be run in this container because go is not installed, so execution verification is from Gitea CI./sop-ack
SECURITY REVIEW APPROVED on head
2756415ddf. I reviewed the 3-file diff for the #2748 base_url fix. No secret/key/base material leak: added tests use placeholders only (mm-key,kimi-key,sk-ant-key) and diff scan found no credential-shaped additions. The production change does not alter token projection or credential selection: it only normalizes provider.BaseURLAnthropic into ANTHROPIC_BASE_URL after the existing BYOK provider/auth projection path has selected the token. Existing redaction/sanitization paths are untouched. Registry/proxy base values remain unchanged, preserving the platform proxy path that still needs /v1; only the direct claude-code adapter env gets the no-double-/v1 base. No security regression found.APPROVED on head
2756415d.5-axis review:
Tests: the new AdapterBaseHasNoDoubleV1 table covers minimax, kimi-coding, and anthropic; the two corrected tests remove the prior defect-baking /v1 expectation. I also verified via grep that BaseURLAnthropic production use is concentrated here and that platform/proxy paths still preserve the proxy env. Required CI/all-required is green on this head; advisory real MiniMax lifecycle is also green. I could not run local Go tests because this container lacks the go toolchain.
/sop-ack