-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Labels
Description
Description
CodeRabbit suggested refactoring buildSandboxEnvArgs to return key-value pairs instead of CLI-formatted args.
The function buildSandboxEnvArgs produces CLI-formatted args (--env, K=V), which are then parsed back into key-value pairs at the call site. This is an indirect approach.
Suggested Refactor
Create a helper that returns the raw key-value pairs, then format as CLI args where needed:
// Returns { key: value } pairs for passthrough env vars
function getPassthroughEnvVars(env: NodeJS.ProcessEnv): Record<string, string> {
const passthroughVariables = [
'LLXPRT_CODE_IDE_SERVER_PORT',
'LLXPRT_CODE_IDE_WORKSPACE_PATH',
'LLXPRT_CODE_WELCOME_CONFIG_PATH',
'TERM_PROGRAM',
];
const result: Record<string, string> = {};
for (const envVar of passthroughVariables) {
const value = env[envVar];
if (value) {
result[envVar] = value;
}
}
return result;
}
export function buildSandboxEnvArgs(env: NodeJS.ProcessEnv): string[] {
const args: string[] = [];
for (const [key, value] of Object.entries(getPassthroughEnvVars(env))) {
args.push('--env', `${key}=${value}`);
}
return args;
}Then use Object.assign(sandboxEnv, getPassthroughEnvVars(process.env)) instead of the parsing loop at the call site.
Location
packages/cli/src/utils/sandbox.ts - buildSandboxEnvArgs function around line 56-73, and usage around line 334-340.
Reference
- CodeRabbit nitpick from PR fix: trigger bucket failover immediately on 429/402/401 errors (#1006) #1009
- Parent issue: Deferred CodeRabbit nitpicks for 0.8.0 #1014