Skip to content

fix(codearts): serve console credential import from the codec - #461

Merged
caigee-cmd merged 1 commit into
caigee-cmd:mainfrom
yoruuuchan:fix/codearts-credential-import
Nov 2, 2026
Merged

caigee-cmd merged 1 commit into
caigee-cmd:mainfrom
yoruuuchan:fix/codearts-credential-import

Conversation

@yoruuuchan

Copy link
Copy Markdown
Contributor

Summary

  • control.Accounts.ImportAll resolves a credential importer with adapter.Credential.(providers.CredentialImporter), but the CodeArts adapter declared Format and PrepareImport on importer{} — the value in Adapter.ImportExport. The type assertion never matched, no provider claimed the format, and the loop returned its final unsupported_format.
  • The console's 导入凭证 / Import credential tab is therefore broken for 码道: pasting a valid codearts-oauth-v1 credential answers 400 unsupported_format, and no account is created. Browser OAuth login is unaffected, which is why this stayed hidden.
  • Every other in-process provider puts these two methods on its credential codec (kimi/import.go:12, and qwenwork asserts the same in its own test), so this PR moves them onto credentialCodec and leaves ImportExport holding ValidateImport + Export only.

Reproduced against the published image, same request body, only the server differs:

POST /api/accounts/import  {"format":"codearts-oauth-v1","provider":"codearts","region":"cn-north-4","credential":{...}}

ghcr.io/caigee-cmd/cli2api:latest (v0.7.26)  -> 400 {"code":"unsupported_format"}
this branch (built from cmd/server)          -> 201 {"id":"acc_...","provider":"codearts"}

Test plan

  • go test ./internal/providers/... ./internal/control/... ./internal/console/... ./internal/app/... ./internal/gateway/... — green
  • go vet ./... — green
  • git diff --check — clean
  • python scripts/release-notes.py validate — green; added changelog/unreleased/codearts-credential-import.md
  • No frontend or worker change, so no npm run sync / worker test needed
  • New coverage: TestS04InterfaceContract now asserts the Adapter.Credential slot itself implements providers.CredentialImporter, and TestCredentialCodecServesConsoleImport drives Format + PrepareImport on an encoded credential — the two halves the console consumes
  • No tokens, auth blobs, raw captures, or host details in the diff

Note for local runners: on my Windows box a clean fb2eb35 checkout already fails TestLoadLocalCredentialMissing, TestRuntimeSpecSelectsCNCLIAndConfigDir, TestStarterEnvSetsRegionAndProxy, TestRepeatedFailuresBackOff, TestBackoffResetsOnKindChange, and the internal/store backup/tempdir cases (backup mode = 666, want 600, locked-file cleanup). Verified by running the same packages in a worktree at fb2eb35. CI does not reproduce them, so it is local-environment noise, not this PR.

Scope

Only the import wiring changes. The ImportExport descriptor capability, the export path's ErrUnsupported answer, PrepareImport's validation, and the OAuth login flow are untouched. The changelog/unreleased/codearts-provider.md fragment from the original provider PR has already shipped in v0.7.26, so this uses a new filename.

control.Accounts.Import resolves the importer through
Adapter.Credential.(providers.CredentialImporter), but the CodeArts adapter
put Format and PrepareImport on the ImportExport slot instead. Every console
import of a codearts-oauth-v1 credential therefore answered
unsupported_format: no importer matched the format and ImportAll fell through
to its final error.

Move the two methods onto credentialCodec, matching kimi and qwenwork, and pin
the wiring in the adapter contract test so the slot cannot drift again.

Verified against a real endpoint: the same POST /api/accounts/import body
answers 400 unsupported_format on the published v0.7.26 image and 201 with a
created account on this branch.
@caigee-cmd
caigee-cmd merged commit 119339b into caigee-cmd:main Nov 2, 2026
6 checks passed
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.

2 participants