{"record":{"id":"df69422e9c208342","repo":"github/copilot-sdk","slug":"githubtoken-and-useloggedinuser-cannot-be-used-wit","errorCode":null,"errorMessage":"gitHubToken and useLoggedInUser cannot be used with RuntimeConnection.forUri (external server manages its own auth)","messagePattern":"gitHubToken and useLoggedInUser cannot be used with RuntimeConnection\\.forUri \\(external server manages its own auth\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodejs/src/client.ts","lineNumber":608,"sourceCode":"     *   connection: RuntimeConnection.forStdio({ path: \"/usr/local/bin/copilot\" }),\n     *   logLevel: \"debug\",\n     * });\n     * ```\n     */\n    constructor(options: CopilotClientOptions = {}) {\n        // Resolve the connection mode. `_internalConnection` is set by\n        // `joinSession()` to opt into the parent-process stdio path; consumers\n        // should always go through the public `connection` field.\n        const conn: InternalRuntimeConnection =\n            options._internalConnection ??\n            options.connection ??\n            CopilotClient.resolveDefaultConnection();\n\n        if (\n            conn.kind === \"uri\" &&\n            (options.gitHubToken !== undefined || options.useLoggedInUser !== undefined)\n        ) {\n            throw new Error(\n                \"gitHubToken and useLoggedInUser cannot be used with RuntimeConnection.forUri (external server manages its own auth)\"\n            );\n        }\n        if (conn.kind === \"inprocess\" && options.workingDirectory !== undefined) {\n            throw new Error(\n                \"workingDirectory is not supported with RuntimeConnection.forInProcess(): the in-process \" +\n                    \"transport hosts the runtime in this process, so honoring it would require mutating the \" +\n                    \"shared process-global cwd. Change the host process's working directory before \" +\n                    \"constructing the client instead.\"\n            );\n        }\n        if (conn.kind === \"inprocess\" && options.env !== undefined) {\n            throw new Error(\n                \"env is not supported with RuntimeConnection.forInProcess(): the in-process transport loads \" +\n                    \"the native runtime into the shared host process, whose single environment block cannot \" +\n                    \"carry per-client values. Set the variables on the host process environment instead.\"\n            );\n        }","sourceCodeStart":590,"sourceCodeEnd":626,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/nodejs/src/client.ts#L590-L626","documentation":"When the session_fs capabilities in the client options declare sqlite support, _initialize_session() type-checks the provider produced by create_session_fs_handler and raises this ValueError if it is not an instance of SessionFsSqliteProvider. Declaring the sqlite capability promises the library a SQLite-backed provider; a plain SessionFsProvider cannot satisfy it.","triggerScenarios":"Client options set session_fs capabilities {\"sqlite\": true}, but the create_session_fs_handler returns a provider class that does not subclass SessionFsSqliteProvider.","commonSituations":"Implementing a custom filesystem provider after enabling sqlite in capabilities copied from an example; refactoring the provider so it no longer inherits SessionFsSqliteProvider; registering a mock/stub in tests while capabilities still declare sqlite.","solutions":["Make the returned provider subclass SessionFsSqliteProvider (from copilot.session_fs_provider) and implement its SQLite methods.","Remove the \"sqlite\" capability from the session_fs capabilities config if SQLite is not actually supported.","Fix create_session_fs_handler so it instantiates the intended SQLite-capable provider."],"exampleFix":"// before\nclass MyFsProvider(SessionFsProvider): ...\ncreate_session_fs_handler=lambda s: MyFsProvider(s)\n// after\nfrom copilot.session_fs_provider import SessionFsSqliteProvider\nclass MyFsProvider(SessionFsSqliteProvider): ...\ncreate_session_fs_handler=lambda s: MyFsProvider(s)","handlingStrategy":"type-guard","validationCode":"from copilot.session_fs_provider import SessionFsSqliteProvider\nprovider = create_session_fs_handler(session)\nif caps.get(\"sqlite\") and not isinstance(provider, SessionFsSqliteProvider):\n    raise TypeError(\"sqlite capability requires a SessionFsSqliteProvider subclass\")","typeGuard":"def is_sqlite_provider(p) -> bool:\n    from copilot.session_fs_provider import SessionFsSqliteProvider\n    return isinstance(p, SessionFsSqliteProvider)","tryCatchPattern":"try:\n    session = await client.create_session(\n        ..., create_session_fs_handler=make_fs_handler)\nexcept ValueError as e:\n    if \"SessionFsSqliteProvider\" in str(e):\n        ...  # fix provider class hierarchy or drop the sqlite capability","preventionTips":["Subclass SessionFsSqliteProvider when declaring the sqlite capability.","Keep the capabilities dict and the provider implementation in sync.","Add a unit test that instantiates your handler and isinstance-checks the result."],"tags":["type-mismatch","session-fs","configuration"],"backgroundTag":"incompatible-source-type","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}