From 3da4ef3a6cc758ccb026bb9a6dd181a298cf417a Mon Sep 17 00:00:00 2001 From: joshavant <830519+joshavant@users.noreply.github.com> Date: Mon, 27 Jul 2026 16:58:09 -0500 Subject: [PATCH] fix(github-copilot): format legacy oauth credentials --- extensions/github-copilot/index.test.ts | 14 ++++++++++++++ extensions/github-copilot/index.ts | 1 + 2 files changed, 15 insertions(+) diff --git a/extensions/github-copilot/index.test.ts b/extensions/github-copilot/index.test.ts index 2dc2489057f5..2c63d83a07da 100644 --- a/extensions/github-copilot/index.test.ts +++ b/extensions/github-copilot/index.test.ts @@ -174,6 +174,20 @@ function registerProviderWithPluginConfig(pluginConfig: Record) } describe("github-copilot plugin", () => { + it("formats legacy OAuth profiles with the durable GitHub credential", () => { + const provider = registerProviderWithPluginConfig({}); + + expect( + provider.formatApiKey?.({ + type: "oauth", + provider: "github-copilot", + access: "short-lived-copilot-token", + refresh: " durable-github-token ", + expires: Date.now() + 60_000, + }), + ).toBe("durable-github-token"); + }); + it("preserves the source token supplied by the auth layer for runtime auth", async () => { mocks.resolveCopilotRuntimeAuth.mockResolvedValueOnce({ apiKey: "github-source-token", diff --git a/extensions/github-copilot/index.ts b/extensions/github-copilot/index.ts index e9cc8d7d8232..5345450c7720 100644 --- a/extensions/github-copilot/index.ts +++ b/extensions/github-copilot/index.ts @@ -600,6 +600,7 @@ export default definePluginEntry({ prepareDynamicModel: dynamicModels.prepareDynamicModel, resolveDynamicModel: dynamicModels.resolveDynamicModel, preferRuntimeResolvedModel: dynamicModels.preferRuntimeResolvedModel, + formatApiKey: (credential) => (credential.type === "oauth" ? credential.refresh.trim() : ""), wrapStreamFn: wrapCopilotProviderStream, buildReplayPolicy: ({ modelId }) => buildGithubCopilotReplayPolicy(modelId), sanitizeReplayHistory: sanitizeGithubCopilotReplayHistory,