fix(zai): reject onboarding command auth profiles#97344
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 28, 2026, 8:40 AM ET / 12:40 UTC. Summary PR surface: Source +112, Tests +169, Docs +3. Total +284 across 11 files. Reproducibility: yes. at source level: current main accepts non-empty Z.AI API-key input and can persist onboarding command text through the setup path. I did not run a live Z.AI credential repro in this read-only review. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the provider-owned Z.AI guard and static doctor hook after maintainer API acceptance, while leaving the linked broader auth-profile issue open for key-rotation and fallback behavior. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main accepts non-empty Z.AI API-key input and can persist onboarding command text through the setup path. I did not run a live Z.AI credential repro in this read-only review. Is this the best way to solve the issue? Mostly yes: putting command detection in the Z.AI provider and keeping core doctor generic is the right ownership shape. The remaining question is whether maintainers want the new optional static doctor hook as the permanent plugin API. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 08d15ec32db3. Label changesLabel justifications:
Evidence reviewedPR surface: Source +112, Tests +169, Docs +3. Total +284 across 11 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
558e5bb to
ad55223
Compare
|
Addressed the ClawSweeper finding about the Z.AI doctor hint being routed only through the OAuth/token formatter. What changed:
Known proof gap: the full source @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
ad55223 to
7705005
Compare
|
Addressed the latest ClawSweeper owner-boundary finding. What changed in
Fresh checks are in the PR body. The Windows Vitest runner still hung locally, so I included that as a proof gap rather than presenting it as passing. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
3544e59 to
d93ffc7
Compare
|
@clawsweeper re-review Addressed the latest hook-contract review by replacing the widened
Fresh proof after the update: All exited 0; |
|
🦞🧹 I asked ClawSweeper to review this item again. |
d93ffc7 to
3171578
Compare
|
@clawsweeper re-review Addressed the two remaining merge blockers from the latest review:
Fresh proof after this update: All exited 0. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review Addressed the latest finding:
Fresh proof after this narrow test-mock repair: All exited 0. I also retried the requested focused test: It still hung on this Windows worktree with no output and was stopped after roughly 120 seconds, matching the previously documented local Vitest runner gap. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Related: #97313
What Problem This Solves
Fixes the Z.AI command-string auth-profile pollution path where users could end up with
zai:defaultstoring onboarding command text such asopenclaw onboard --auth-choice zai-coding-globalas the API key, causing provider calls to use that command string as the bearer token instead of a real key.Why This Change Was Made
The setup guard is owned by the Z.AI provider: interactive and non-interactive Z.AI API-key auth now reject onboarding command text before the value can be persisted.
The doctor path is split by ownership:
buildStaticAuthProfileDoctorHint.buildAuthDoctorHinthook only.buildStaticAuthProfileDoctorHint.This addresses the ClawSweeper hook-contract review: the existing OAuth hook contract is unchanged, and static API-key doctor hints use a separate opt-in seam.
The latest update also addresses the remaining merge blockers:
openclaw onboard --non-interactive --auth-choice zai-coding-global --zai-api-key "$ZAI_API_KEY", plus--auth-choice=zai-coding-global.buildStaticAuthProfileDoctorHintand distinguish it from OAuth-onlybuildAuthDoctorHint.This PR does not change sub-agent fallback behavior or broader key-rotation semantics; those remain with the linked issue scope.
User Impact
Users get an immediate setup error if they paste an OpenClaw onboarding command where a Z.AI API key is expected. Existing polluted
zai:defaultprofiles can be surfaced by doctor asstatic [invalid_api_key]with a provider-owned re-authentication hint, instead of repeatedly failing as an opaque Z.AI 401.Evidence
Red/green proof from the initial fix:
Before the fix, the new regression tests failed because Z.AI returned a profile with
key: "openclaw onboard --auth-choice zai-coding-global"and doctor returned an empty hint. After the fix: 2 files passed, 19 tests passed.Focused proof before later Windows runner hangs:
Results from earlier successful runs: doctor-auth profile health passed 1 file / 6 tests, then the combined focused proof passed 3 files / 25 tests.
Fresh checks after replacing the widened hook design with a static-specific opt-in hook:
All exited 0. The
rgcommand exited 1 with no matches, confirming the temporaryissueKinddesign and temporary static context type are gone.plugin-sdk-surface-report.mjs --checkpassed with unchanged public package SDK export count andpackage-exported forbidden subpaths: 0.Fresh checks after the documented command-variant and docs follow-up:
All exited 0.
pnpm docs:check-mdxpassed for 684 files.Current Windows proof gap:
These did not complete on this Windows worktree; the focused Z.AI test wrapper was stopped after 150 seconds with no output. Raw Vitest reruns also previously hung during Rolldown/Vitest initialization with repeated
[PLUGIN_TIMINGS]warnings and no test failure summary. The focused suites above passed before this runner issue, and the fresh direct provider assertions plus lint/format/import/docs/surface checks cover the latest code movement.Validation note: I do not have a live Z.AI / GLM-5.2 credential, so this PR proves the local auth-profile root cause with seeded/plugin/doctor-path evidence rather than a live network call.