fix(canvas): platform-managed provider needs no user credential (#2245) #2246
Reference in New Issue
Block a user
Delete Branch "fix/2245-platform-managed-no-cred"
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?
Problem
Live repro on
molecule-adk-demo(git_sha9fbb5468= current main): the Create-workspace dialog with Provider = "Platform (N models)" blocks on "Provider credential is required" even though platform-managed needs no user key (its own help text says "No vendor API key is required").Root cause
CreateWorkspaceDialog.tsx:293required a credential whenever the selected provider declared anyenvVars, with no platform-managed exemption. The platform provider declaresMOLECULE_LLM_USAGE_TOKEN(registry_gen.go:53,IsPlatform:true), but that token is the tenant admin_token injected by the CP provisioner (ec2.go:2385→MOLECULE_LLM_USAGE_TOKEN="$ADMIN_TOKEN") — internal plumbing, not a user input. Three wrong behaviors followed: (1) validation required it; (2) a credential field rendered for the internal token; (3) create would sendsecrets:{MOLECULE_LLM_USAGE_TOKEN:""}, clobbering the injected token (latent until the validation is loosened — so the fix covers all three).Fix
isPlatformManagedProvider(p) = p.vendor==="platform" || p.billingMode==="platform_managed". Gate the validation, the credential-field render, and the secret-send on it. Platform-managed now shows "Platform-managed — no API key required" and sends no secret. BYOK is unchanged.Tests (Phase 3)
CreateWorkspaceDialog.test.tsx: platform-managed-WITH-auth-env -> no credential required, field hidden, nosecretsin payload; BYOK -> still required + field rendered (no-regression); +isPlatformManagedProviderunit cases.platformprovider hadrequired_env:[]); the new fixture matches production (auth_envcarriesMOLECULE_LLM_USAGE_TOKEN).Verification scope
Frontend-only. Stage A/C covered by the discriminating vitest + watch-it-fail. Browser / Stage-B verification on the demo tenant follows after merge + deploy (the fix can't be browser-tested live until deployed).
Risk
tier:low — canvas-only, reversible by
git revert.Fixes #2245
The Create-workspace dialog blocked submission with "Provider credential is required" for the platform-managed provider, even though platform- managed mode injects its own usage token (MOLECULE_LLM_USAGE_TOKEN = the tenant admin_token, set by the CP provisioner) and the user supplies no key. The validation keyed only off envVars.length, with no exemption for platform-managed; it also rendered a credential field for the internal token and would have sent secrets:{MOLECULE_LLM_USAGE_TOKEN:""} on create, clobbering the provisioner-injected token. Add isPlatformManagedProvider() (vendor==="platform" || billingMode==="platform_managed") and gate the validation, the credential-field render, and the secret-send on it. Platform-managed now shows "no API key required" and sends no secret; BYOK is unchanged. Tests: discriminating vitest (watch-it-fail verified red->green) — a platform-managed provider WITH a declared auth env requires no credential, hides the field, and sends no secret; BYOK still requires + renders the field; + isPlatformManagedProvider unit cases. The prior mock masked the bug by giving the platform provider required_env:[] — the new fixture matches production (auth_env carries MOLECULE_LLM_USAGE_TOKEN). Fixes #2245 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>Independent review (automated, pre-merge)
An independent reviewer examined this diff, treating the fix as a hypothesis to refute. Verdict: APPROVE — no Critical/Required findings. The discriminator matches the server-side SSOT (
billingMode=="platform_managed"iffIsPlatform()iff provider nameplatform), all three gates (validation / render / secret-send) are correct, and the empty-secret-clobber is genuinely prevented (thesecretskey is omitted, not sent empty).Findings dispositioned:
vendor==="platform"branch; production uses the registry-backedbillingModepath. Added a registry-backed fixture (platformauth_env:[MOLECULE_LLM_USAGE_TOKEN]+billing_mode:platform_managed) that drives suppression end-to-end throughbuildProviderCatalogFromRegistry— commit911d9ce3, watch-it-fail verified red→green.MissingKeysModal+ConfigTabshare the same provider/secret shape and should receive the sameisPlatformManagedProvidergating — filed as a separate audit issue.isPlatformManagedProviderunit tests document the discriminator but the load-bearing discrimination is the integration tests (both branches verified red→green); one comment carries an unpinned cross-repo reference to controlplaneec2.go.No regressions (full canvas suite green); eslint + tsc clean on the changed source files.
This is one independent review on the record. Per
mainbranch protection, merge still requires 2 non-author approvals + the 3 required CI contexts green — this PR is not force-merged.5-axis review for molecule-core#2246 at head
acdb368a4f.Decision: APPROVED.
Author identity: core-devops (Molecule AI · core-devops). Catch-65 Kimi/MiniMax dual-identity ban does not apply based on PR metadata: author is not agent-coder/agent-dev-a/Kimi or MiniMax/DEV-B.
Correctness: The fix correctly distinguishes platform-managed providers from BYOK providers via vendor=="platform" or billingMode=="platform_managed". It suppresses the credential validation, hides the secret field, and omits secrets from the create payload for platform-managed providers, avoiding clobbering the provisioner-injected MOLECULE_LLM_USAGE_TOKEN. BYOK validation remains intact.
Robustness: The restored source covers both legacy/vendor and registry billingMode paths. Tests include production-shaped platform auth_env fixtures, assert no credential field and no secrets payload for platform-managed providers, and assert BYOK providers still require credentials.
Security: This reduces accidental handling of an internal platform token as user input and avoids sending an empty secret that could overwrite platform-managed credentials. No new auth bypass or secret exposure found.
Performance: UI-only branching and helper checks are negligible.
Readability: The helper centralizes the platform-managed predicate and comments explain why MOLECULE_LLM_USAGE_TOKEN is internal plumbing rather than user input.
Merge-readiness: Mergeable=true. Code/test contexts shown are green; combined status is red only due review-gate contexts awaiting approvals. No blocking findings.