{"record":{"id":"c947087bc4966024","repo":"github/copilot-sdk","slug":"githubtoken-and-githubtokenprovider-are-mutually-e","errorCode":null,"errorMessage":"gitHubToken and gitHubTokenProvider are mutually exclusive","messagePattern":"gitHubToken and gitHubTokenProvider are mutually exclusive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodejs/src/client.ts","lineNumber":1511,"sourceCode":"        try {\n            await session.rpc.options.update(patch);\n        } catch (e) {\n            // The runtime session exists but the post-create options\n            // patch failed — best-effort disconnect so we don't leak\n            // it (in empty mode it would otherwise keep running with\n            // permissive defaults).\n            try {\n                await session.disconnect();\n            } catch {\n                // Swallow: original error is the one the caller needs.\n            }\n            throw e;\n        }\n    }\n\n    async createSession(config: SessionConfig): Promise<CopilotSession> {\n        if (config.gitHubToken !== undefined && config.gitHubTokenProvider !== undefined) {\n            throw new Error(\"gitHubToken and gitHubTokenProvider are mutually exclusive\");\n        }\n        if (!this.connection) {\n            await this.start();\n        }\n\n        const modeDefaults = this.configDefaultsForMode();\n        config = { ...modeDefaults, ...config };\n        config.customAgentsLocalOnly ??= modeDefaults.customAgentsLocalOnly;\n        config.systemMessage = this.getSystemMessageConfigForMode(config.systemMessage);\n\n        // For cloud sessions, let the CLI/server assign the session id and\n        // register the session lazily once the response arrives. For non-cloud\n        // sessions we generate the id client-side (when the caller didn't\n        // supply one) so the session can be registered BEFORE the RPC — the\n        // CLI may issue session-scoped requests (e.g. `sessionFs.writeFile`\n        // for workspace metadata) during `session.create` processing, before\n        // it has sent the response.\n        const callerSessionId = config.sessionId;","sourceCodeStart":1493,"sourceCodeEnd":1529,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/nodejs/src/client.ts#L1493-L1529","documentation":"Session-creation option validation: the SessionConfig supplied both gitHubToken (an inline token value) and gitHubTokenProvider (a provider callback/object). These are alternative ways to supply GitHub auth, and the client rejects configs that set both because precedence would be ambiguous.","triggerScenarios":"Thrown at nodejs/src/client.ts:1511 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Keep gitHubToken for a static token, or gitHubTokenProvider for dynamic token acquisition — never both","Remove whichever auth mechanism you are not using from the session config","If migrating from static to provider-based tokens, delete the old gitHubToken field rather than leaving it set"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}