-
Notifications
You must be signed in to change notification settings - Fork 964
fix(desktop): unblock AI branch/workspace naming for OAuth-only users + dev placeholders #3580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+232
−89
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b0f8577
fix(desktop): unblock AI branch/workspace naming for OAuth-only users…
AviPeltz 5854b62
review: address self-review feedback on small-model OAuth fix
AviPeltz 2205044
test(chat): add OAuth refresh integration tests with mocked fs + fetch
AviPeltz 93d1122
review: address second-pass feedback on small-model OAuth fix
AviPeltz 4c43772
review: address PR review-bot feedback
AviPeltz bafc03a
fix(chat): isolate OAuth test fs mocking to prevent leakage to siblin…
AviPeltz 0a00d96
refactor(chat): use mastracode for OAuth instead of reimplementing
AviPeltz a7d8248
fix(chat): prefer apikey:<provider> slot over main slot in get-small-…
AviPeltz d067412
chore(branch-naming): nudge LLM toward 20 chars or less
AviPeltz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| export const ANTHROPIC_AUTH_PROVIDER_ID = "anthropic"; | ||
| export const OPENAI_AUTH_PROVIDER_ID = "openai-codex"; | ||
| export const OPENAI_AUTH_PROVIDER_IDS = [ | ||
| export { | ||
| ANTHROPIC_AUTH_PROVIDER_ID, | ||
| OPENAI_AUTH_PROVIDER_ID, | ||
| "openai", | ||
| ] as const; | ||
| OPENAI_AUTH_PROVIDER_IDS, | ||
| } from "../../shared/auth-provider-ids"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| export const ANTHROPIC_AUTH_PROVIDER_ID = "anthropic"; | ||
| export const OPENAI_AUTH_PROVIDER_ID = "openai-codex"; | ||
| // Mastracode historically wrote OpenAI under "openai" before the Codex split. | ||
| // Read both when resolving credentials. | ||
| export const OPENAI_AUTH_PROVIDER_IDS = [ | ||
| OPENAI_AUTH_PROVIDER_ID, | ||
| "openai", | ||
| ] as const; |
58 changes: 58 additions & 0 deletions
58
packages/chat/src/server/shared/small-model/get-small-model.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { describe, expect, it } from "bun:test"; | ||
| import { isAnthropicApiKey, isOpenAIApiKey } from "./get-small-model"; | ||
|
|
||
| describe("isAnthropicApiKey", () => { | ||
| it("accepts a real-shaped key", () => { | ||
| expect( | ||
| isAnthropicApiKey( | ||
| "sk-ant-api03-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | ||
| ), | ||
| ).toBe(true); | ||
| }); | ||
|
|
||
| it("rejects dev placeholders", () => { | ||
| expect(isAnthropicApiKey("dummy")).toBe(false); | ||
| expect(isAnthropicApiKey("placeholder")).toBe(false); | ||
| expect(isAnthropicApiKey("")).toBe(false); | ||
| }); | ||
|
|
||
| it("rejects OAuth access tokens (sk-ant-oat…) sent as api keys", () => { | ||
| // OAuth tokens fail when sent via x-api-key. Filter them so we fall | ||
| // through to the OAuth path which sends them via Authorization Bearer. | ||
| expect( | ||
| isAnthropicApiKey("sk-ant-oat-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), | ||
| ).toBe(false); | ||
| }); | ||
|
|
||
| it("rejects keys with the prefix but absurd lengths", () => { | ||
| expect(isAnthropicApiKey("sk-ant-api")).toBe(false); | ||
| }); | ||
|
|
||
| it("rejects unrelated provider keys", () => { | ||
| expect(isAnthropicApiKey("sk-proj-foo")).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe("isOpenAIApiKey", () => { | ||
| it("accepts legacy, project, and service-account key shapes", () => { | ||
| expect( | ||
| isOpenAIApiKey("sk-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), | ||
| ).toBe(true); | ||
| expect( | ||
| isOpenAIApiKey("sk-proj-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), | ||
| ).toBe(true); | ||
| expect( | ||
| isOpenAIApiKey("sk-svcacct-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), | ||
| ).toBe(true); | ||
| }); | ||
|
|
||
| it("rejects dev placeholders and obviously-fake values", () => { | ||
| expect(isOpenAIApiKey("dummy")).toBe(false); | ||
| expect(isOpenAIApiKey("sk-")).toBe(false); | ||
| expect(isOpenAIApiKey("")).toBe(false); | ||
| }); | ||
|
|
||
| it("rejects values without the sk- prefix", () => { | ||
| expect(isOpenAIApiKey("api-key-aaaaaaaaaaaaaaaaaaaaaaaaaaaaa")).toBe(false); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.