GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(oauth): stop OAuth login from deleting a stored provider API key by wonsh42 · Pull Request #491 · lidge-jun/opencodex Conversation
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthrough
ChangesOAuth credential preservation
Release version
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
✅ Target branch corrected This pull request now targets The |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@lidge-jun 수정해주삼 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
ㄱㄷㄱㄷ 지금 클로드 데스크탑이랑 그록 작업중 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
ㄳㄳ 나 또 버그(?) 발견했는데 수정해서 pr 올려드림 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
클로드 데스크톱도 되게 할꺼임? cli만 돼서 불편하던데 (내가 기능을 못찾았던건가?) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
8eca4eb to
73aa7f2
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
src/oauth/index.ts (1)
618-631: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winPreserve key mode when
authModeis omitted
src/providers/api-keys.tsnever writesauthModefor API-key providers, so persistedxai/github-copilotentries can legitimately have an undefined mode. Insrc/oauth/index.ts:628-629, the strictexisting.authMode === "key"check then skips restoration and the provider falls back to the OAuth preset, even though a validapiKey/apiKeyPoolis present.Treat an omitted
authModeas key-mode here, e.g. restore"key"whenstoredApiKeyexists andexisting.authModeis either"key"orundefined.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/oauth/index.ts` around lines 618 - 631, The key-mode restoration in upsertOAuthProvider currently requires existing.authMode to equal "key", so persisted API-key providers with an omitted mode lose their key authentication. Update the condition in upsertOAuthProvider to set next.authMode to "key" when storedApiKey exists and existing.authMode is either "key" or undefined, while preserving other provider behavior.
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/oauth/index.ts`:
- Around line 618-631: The key-mode restoration in upsertOAuthProvider currently
requires existing.authMode to equal "key", so persisted API-key providers with
an omitted mode lose their key authentication. Update the condition in
upsertOAuthProvider to set next.authMode to "key" when storedApiKey exists and
existing.authMode is either "key" or undefined, while preserving other provider
behavior.
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: e42901d8-dbc9-4d27-a5d7-3748cd2e5e89
src/oauth/index.tstests/oauth-upsert-preserves-api-key.test.ts
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Request changes — do not merge until the PR is rebased/merged onto current dev and the package.json conflict is resolved without regressing the published version. Optional follow-ups are not accepted for this PR; all quality items below must ship in this PR before merge.
Target branch is correctly dev. The OAuth upsert fix itself is sound and well-tested: for allowKeyAuthOverride providers (xai, github-copilot), upsertOAuthProvider now preserves sanitized apiKey / apiKeyPool and keeps an explicit authMode: "key" only while a valid active key remains, matching router.ts's authMode === "key" gate. The follow-up commit correctly restores OAuth mode after final key removal. GitHub currently reports mergeable: CONFLICTING, mergeStateStatus: DIRTY.
dev (mergeable=CONFLICTING, mergeStateStatus=DIRTY).
e0debe22 into dev @ 58f0fab): package.json only.dev: "version": "2.7.41""version": "2.7.40"src/oauth/index.ts and tests/oauth-upsert-preserves-api-key.test.ts apply cleanly.dev into this branch and resolve in this PR before merge. When resolving, keep 2.7.41 (current dev) — do not downgrade to 2.7.40. Prefer dropping the release: v2.7.40 / version-bump commit from this bugfix entirely; version bumps belong to maintainer release promotion, not a contributor OAuth fix.package.json 2.7.35 → 2.7.40 via commit 66de25ad (release: v2.7.40). That is out of scope for this fix and is what conflicts with dev's 2.7.41. Resolve by taking dev's version (no version change in this PR).e0debe22 is action_required (fork PR), not a green suite on the current tip. After rebase/conflict resolution, ensure Cross-platform CI / typecheck / tests pass on the mergeable SHA (earlier success on 8eca4eb does not cover the follow-up commit + rebase).authMode with a stored key (CodeRabbit / related). src/oauth/index.ts:629 only restores authMode: "key" when existing.authMode === "key". Fix in this PR so a preserved/sanitized active key (or equivalent key material that should keep key billing) also results in explicit authMode: "key" when mode was omitted, and align with router.ts / account semantics as needed so key override is not lost. Cover with a focused regression test.tests/... "rejects an unsafe active key…"): today this drops the active key, keeps the pool, and falls back to oauth. In this PR, promote the first safe pool entry into apiKey and keep key mode when a valid pool alternate exists (instead of falling back to oauth while pool keys remain usable).src/providers/api-keys.ts CRLF/trim checks where practical on this write path, rather than leaving a parallel defensive copy as follow-up polish.None. Do not defer quality work to a follow-up PR; ship the items above in this PR.
2.7.41 → 2.7.40). No Node-only APIs introduced.allowKeyAuthOverride providers). OAuth-only providers still get a plain preset overwrite. No linked GitHub issue; PR body is the effective spec — implementation aligns. No docs change needed for this internal write-path fix.| Gate | Status |
|---|---|
| Base branch | dev (correct; wrong-branch enforcer already corrected earlier) |
mergeable / mergeStateStatus |
CONFLICTING / DIRTY — blocking |
| Conflicted files | package.json |
Cross-platform CI (tip e0debe22) |
action_required (needs fork approval / not green on tip) |
| Enforce PR target / label / CodeRabbit | pass |
| Prior full CI success | 8eca4eb only (pre follow-up) |
Event: request-changes
Once all blocking + required quality changes above are addressed (and conflicts/rebase done), mark this PR Ready for review (leave draft only until then). Then ping for re-review / CI.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Two read-only audit lenses returned 30 contradictions; the verified ones are applied here and recorded in 006_corrections.md. Factual corrections: - claude-code#1124 closed 2025-05-16, not 2025-08-10 - 13 open enhancement issues, not 11 - #529 is merged, so issue #42 phase 2 is done - #418 has no PR behind it; it was miscounted as in-flight - #528 does not contain #424's current head, so it needs a rebase - #527's retarget is manual and independent of #526 Framing corrections: - stale-needs-info.yml is absent from the default branch, so bundle C had no real deadline - the debug switch #543's reporter asked for already exists - whether #545 is our defect is answerable from code, not owner judgment - #491 is an OAuth credential change, so it is a security boundary rather than a warm-up; #533 and #447 keep their security classification too Structure: bundle G added for roadmap honesty, bundle F rescoped to the security boundary, #498 split out of bundle B, cycle order rebuilt, and the loop archetype corrected to decision-elicitation.
`upsertOAuthProvider` replaced the provider entry with the bare preset on every OAuth login. For providers that can be billed either way (`allowKeyAuthOverride`: xai, github-copilot) this deleted `apiKey` and `apiKeyPool` from config.json and silently flipped an explicit `authMode: "key"` billing choice back to the subscription — the key was gone and had to be pasted again. Carry the key fields over and keep an explicitly chosen `authMode: "key"`, so logging in never changes which credential bills the request. OAuth-only providers and fresh logins still get the untouched preset.
…omitted Address review follow-ups so OAuth login preserves key billing when a usable key remains, including pool promotion and shared API-key sanitization.
e0debe2 to
aa4b99b
Compare
|
Maintainer takeover update for PR #491:
Waiting on CI on the rebased tip before merge. This path touches OAuth config writes — still needs maintainer security glance before merge. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Keep list/switch/remove aligned with routing after OAuth upsert, and only restore authMode key when resolveEnvValue yields a usable secret.
Avoid POST /api/providers with the bare OAuth preset, which dropped preserved apiKey/authMode and wrote that stripped state back to disk.
…runtime Stop upsertOAuthProvider from gating authMode on resolveEnvValue in the login CLI; router falls back to OAuth when the proxy cannot resolve an env-backed active key without rewriting stored mode.
There was an error while loading. Please reload this page.
|
Merged — thank you @wonsh42 for catching this and for the clear repro. OAuth login on Appreciate the contribution. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…idge-jun#491) * fix(oauth): stop OAuth login from deleting a stored provider API key `upsertOAuthProvider` replaced the provider entry with the bare preset on every OAuth login. For providers that can be billed either way (`allowKeyAuthOverride`: xai, github-copilot) this deleted `apiKey` and `apiKeyPool` from config.json and silently flipped an explicit `authMode: "key"` billing choice back to the subscription — the key was gone and had to be pasted again. Carry the key fields over and keep an explicitly chosen `authMode: "key"`, so logging in never changes which credential bills the request. OAuth-only providers and fresh logins still get the untouched preset. * fix(oauth): restore OAuth mode after final key removal * fix(oauth): promote safe pool key and keep key mode when authMode is omitted Address review follow-ups so OAuth login preserves key billing when a usable key remains, including pool promotion and shared API-key sanitization. * fix(oauth): sync active key into pool and gate key mode on resolved env Keep list/switch/remove aligned with routing after OAuth upsert, and only restore authMode key when resolveEnvValue yields a usable secret. * fix(oauth): push merged provider config to running proxy after CLI login Avoid POST /api/providers with the bare OAuth preset, which dropped preserved apiKey/authMode and wrote that stripped state back to disk. * fix(oauth): persist key intent without CLI env and route env keys at runtime Stop upsertOAuthProvider from gating authMode on resolveEnvValue in the login CLI; router falls back to OAuth when the proxy cannot resolve an env-backed active key without rewriting stored mode. --------- Co-authored-by: wonsh42 <[email protected]> Co-authored-by: wonsh42 <[email protected]> Co-authored-by: Wibias <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.