{"record":{"id":"c558e36f99ee2061","repo":"github/copilot-sdk","slug":"client-is-not-connected-call-start-first","errorCode":null,"errorMessage":"Client is not connected. Call start() first.","messagePattern":"Client is not connected\\. Call start\\(\\) first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodejs/src/client.ts","lineNumber":506,"sourceCode":"    private negotiatedProtocolVersion: number | null = null;\n    /** Connection-level session filesystem config, set via constructor option. */\n    private sessionFsConfig: SessionFsConfig | null = null;\n    private requestHandler: CopilotRequestHandler | null = null;\n    private builtinPluginDirectories: string[] = [];\n    private onGitHubTelemetry?: (notification: GitHubTelemetryNotification) => void | Promise<void>;\n    private clientGlobalHandlers: import(\"./generated/rpc.js\").ClientGlobalApiHandlers = {};\n    private githubTokenProviders = new Map<\n        string,\n        { provider: GitHubTokenProvider; sessionId?: string; committed: boolean }\n    >();\n\n    /**\n     * Typed server-scoped RPC methods.\n     * @throws Error if the client is not connected\n     */\n    get rpc(): ReturnType<typeof createServerRpc> {\n        if (!this.connection) {\n            throw new Error(\"Client is not connected. Call start() first.\");\n        }\n        if (!this._rpc) {\n            this._rpc = createServerRpc(this.connection);\n        }\n        return this._rpc;\n    }\n\n    /**\n     * Internal RPC surface (e.g. handshake helpers). Not part of the public API.\n     * @internal\n     */\n    private get internalRpc(): ReturnType<typeof createInternalServerRpc> {\n        if (!this.connection) {\n            throw new Error(\"Client is not connected. Call start() first.\");\n        }\n        if (!this._internalRpc) {\n            this._internalRpc = createInternalServerRpc(this.connection);\n        }","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/nodejs/src/client.ts#L488-L524","documentation":"CopilotClient.create_session() validates the ask_user_variant argument against the fixed set (None, \"legacy\", \"elicitation\") and raises this ValueError for any other value. It selects which ask-user/permission-prompt protocol variant the session uses, so only the two named variants exist.","triggerScenarios":"Calling create_session(ask_user_variant=...) with a misspelled or unsupported value such as \"Elicitation\", \"legacy \", \"new\", or a non-string value.","commonSituations":"Typo or wrong casing when copying an example; passing a config value read from YAML/JSON without normalization; copying a variant name from a newer or older SDK version that supports different values.","solutions":["Change ask_user_variant to exactly \"legacy\" or \"elicitation\" (lowercase).","Omit ask_user_variant entirely to use the library default (None).","If the value comes from user config, validate/normalize it (strip, lowercase) and check membership before the call.","Check the installed SDK version's supported variants if a documented value is rejected."],"exampleFix":"// before\nawait client.create_session(ask_user_variant=\"Elicitation\")\n// after\nawait client.create_session(ask_user_variant=\"elicitation\")","handlingStrategy":"validation","validationCode":"VALID_VARIANTS = {None, \"legacy\", \"elicitation\"}\nif ask_user_variant not in VALID_VARIANTS:\n    raise ValueError('ask_user_variant must be \"legacy\" or \"elicitation\"')","typeGuard":null,"tryCatchPattern":"try:\n    await client.create_session(ask_user_variant=variant)\nexcept ValueError as e:\n    if \"ask_user_variant\" in str(e):\n        await client.create_session()  # fall back to default","preventionTips":["Use an enum or Literal type for ask_user_variant in your wrappers.","Normalize config strings (strip/lowercase) before passing.","Never hardcode variant strings inline; use a shared constant."],"tags":["argument-validation","enum","python"],"backgroundTag":"invalid-enum-value","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"}