{"record":{"id":"1fbf2b7319641bc4","repo":"github/copilot-sdk","slug":"set-environment-variables-via-either-the-client-le","errorCode":null,"errorMessage":"Set environment variables via either the client-level env option or the connection's env (RuntimeConnection.forStdio/forTcp), not both. Prefer the connection-level env for child-process transports.","messagePattern":"Set environment variables via either the client-level env option or the connection's env \\(RuntimeConnection\\.forStdio/forTcp\\), not both\\. Prefer the connection-level env for child-process transports\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodejs/src/client.ts","lineNumber":640,"sourceCode":"                \"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        }\n        if (conn.kind === \"inprocess\" && options.telemetry !== undefined) {\n            throw new Error(\n                \"telemetry is not supported with RuntimeConnection.forInProcess(): telemetry configuration \" +\n                    \"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) {","sourceCodeStart":622,"sourceCodeEnd":658,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/nodejs/src/client.ts#L622-L658","documentation":"Like create_session, resume_session() accepts either a static github_token or a dynamic github_token_provider, and raises this ValueError when both are supplied. The two credential mechanisms are alternatives; supplying both is treated as a config/programming error and rejected before the resume RPC is issued.","triggerScenarios":"Calling resume_session(...) with both github_token and github_token_provider not None - typically because credential options are merged from env vars and code, or a wrapper forwards both unconditionally.","commonSituations":"Refactoring from static tokens to provider-based auth while leaving the old argument; shared helper functions with two credential parameters where callers populate both; test fixtures setting both for safety.","solutions":["Supply exactly one: remove github_token or github_token_provider from the resume_session call.","Keep github_token_provider if tokens need refresh; keep github_token for simple static credentials.","Audit wrappers/helpers to forward at most one credential option."],"exampleFix":"// before\nawait client.resume_session(\n    \"session-123\",\n    github_token=token,\n    github_token_provider=provider,\n)\n// after\nawait client.resume_session(\n    \"session-123\",\n    github_token_provider=provider,\n)","handlingStrategy":"validation","validationCode":"if github_token is not None and github_token_provider is not None:\n    raise ValueError(\"Pass either github_token or github_token_provider, not both\")","typeGuard":null,"tryCatchPattern":"try:\n    await client.resume_session(\"session-123\", **cred_kwargs)\nexcept ValueError as e:\n    if \"mutually exclusive\" in str(e):\n        cred_kwargs.pop(\"github_token\", None)\n        await client.resume_session(\"session-123\", **cred_kwargs)","preventionTips":["Apply the same single-credential rule to every session API (create and resume).","Have credential helpers return exactly one of token/provider.","Lint or test fixtures that set both credential fields."],"tags":["argument-validation","authentication","python"],"backgroundTag":"mutually-exclusive-options","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"}