Bug Description
When the GIT_CONFIG_COUNT environment variable contains an invalid (non-numeric) value, the parsing logic in shellExecutionService.ts produces NaN instead of defaulting to a safe value.
Location
packages/core/src/services/shellExecutionService.ts:409
const gitConfigCount = parseInt(baseEnv['GIT_CONFIG_COUNT'] || '0', 10);
Problem
If GIT_CONFIG_COUNT contains a non-numeric string (e.g., "invalid", "abc123", or any corrupted value), parseInt returns NaN. This causes:
GIT_CONFIG_KEY_NaN and GIT_CONFIG_VALUE_NaN to be created as environment variable names
GIT_CONFIG_COUNT to be set to "NaN" (string)
- Potential silent failures in git operations that depend on these environment variables
Steps to Reproduce
- Set
GIT_CONFIG_COUNT=invalid in the environment
- Run a shell command through Gemini CLI in non-interactive mode
- Observe that the environment variables are corrupted with NaN values
Expected Behavior
The code should validate the parsed integer and default to 0 if the value is NaN, ensuring git configuration environment variables are always valid.
Proposed Fix
const parsedCount = parseInt(baseEnv['GIT_CONFIG_COUNT'] || '0', 10);
const gitConfigCount = Number.isNaN(parsedCount) ? 0 : parsedCount;
Environment
- OS: All platforms
- Node.js: >=20.0.0
Bug Description
When the
GIT_CONFIG_COUNTenvironment variable contains an invalid (non-numeric) value, the parsing logic inshellExecutionService.tsproducesNaNinstead of defaulting to a safe value.Location
packages/core/src/services/shellExecutionService.ts:409Problem
If
GIT_CONFIG_COUNTcontains a non-numeric string (e.g.,"invalid","abc123", or any corrupted value),parseIntreturnsNaN. This causes:GIT_CONFIG_KEY_NaNandGIT_CONFIG_VALUE_NaNto be created as environment variable namesGIT_CONFIG_COUNTto be set to"NaN"(string)Steps to Reproduce
GIT_CONFIG_COUNT=invalidin the environmentExpected Behavior
The code should validate the parsed integer and default to
0if the value isNaN, ensuring git configuration environment variables are always valid.Proposed Fix
Environment