{"record":{"id":"d8175edc1ba2ec0f","repo":"github/copilot-sdk","slug":"connectiontoken-must-be-a-non-empty-string","errorCode":null,"errorMessage":"connectionToken must be a non-empty string","messagePattern":"connectionToken must be a non-empty string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodejs/src/client.ts","lineNumber":648,"sourceCode":"                    \"is lowered to environment variables read by native runtime code running in the shared \" +\n                    \"host process, so per-client telemetry cannot be honored in-process. Configure telemetry \" +\n                    \"via the host process environment, or use a child-process transport.\"\n            );\n        }\n        if (\n            (conn.kind === \"stdio\" || conn.kind === \"tcp\") &&\n            conn.env !== undefined &&\n            options.env !== undefined\n        ) {\n            throw new Error(\n                \"Set environment variables via either the client-level env option or the connection's env \" +\n                    \"(RuntimeConnection.forStdio/forTcp), not both. Prefer the connection-level env for \" +\n                    \"child-process transports.\"\n            );\n        }\n        if (conn.kind === \"tcp\" && conn.connectionToken !== undefined) {\n            if (typeof conn.connectionToken !== \"string\" || conn.connectionToken.length === 0) {\n                throw new Error(\"connectionToken must be a non-empty string\");\n            }\n        }\n\n        this.connectionConfig = conn;\n\n        if (options.sessionFs) {\n            this.validateSessionFsConfig(options.sessionFs);\n        }\n        if (options.builtinPluginDirectories) {\n            for (const path of options.builtinPluginDirectories) {\n                if (!isAbsolute(path)) {\n                    throw new Error(\n                        `builtinPluginDirectories must contain only absolute paths: ${path}`\n                    );\n                }\n            }\n            this.builtinPluginDirectories = [...options.builtinPluginDirectories];\n        }","sourceCodeStart":630,"sourceCodeEnd":666,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/nodejs/src/client.ts#L630-L666","documentation":"resume_session() validates ask_user_variant against the allowed set (None, \"legacy\", \"elicitation\") and raises this ValueError for any other value. It chooses the ask-user prompt protocol for the resumed session; only these two variants are implemented.","triggerScenarios":"Calling resume_session(ask_user_variant=...) with any value other than exactly \"legacy\" or \"elicitation\" (wrong casing, whitespace, synonyms like \"new\", or non-string values from unvalidated config).","commonSituations":"Copy-paste from docs for a different SDK version; config values read from YAML/JSON without normalization; case-sensitive comparison tripping up values like \"Elicitation\".","solutions":["Use exactly \"legacy\" or \"elicitation\" (lowercase) or omit the argument for the default.","Normalize/validate externally supplied values before passing them in.","Verify the installed SDK version supports the variant you intend to use."],"exampleFix":"// before\nawait client.resume_session(\"session-123\", ask_user_variant=\"Elicitation\")\n// after\nawait client.resume_session(\"session-123\", 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.resume_session(\"session-123\", ask_user_variant=variant)\nexcept ValueError as e:\n    if \"ask_user_variant\" in str(e):\n        await client.resume_session(\"session-123\")  # default variant","preventionTips":["Share one validated constant/enum for ask_user_variant across create and resume calls.","Normalize externally sourced values before use.","Pin SDK versions so documented variant values match the implementation."],"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"}