bug: non-numeric background-PID lines become NaN entries in shell tool output (missing continue)
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 91/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- cli
Research direction
Start in packages/core/src/tools/shell.ts:750-764 and inspect the loop that parses backgroundPIDLines. Reproduce with a stray non-numeric line if needed, then verify that it is logged and skipped while valid PIDs still appear in the tool output without NaN entries.
Written by the indexing model from the issue text.
Description
What happened?
When parsing the background-PID file emitted by backgrounded shell commands, non-numeric lines that aren't recognized sysmond messages are logged as errors — and then control falls through to Number(line), pushing NaN into backgroundPIDs. The result is rendered in the tool output as Background PIDs: NaN. A continue after the error log was clearly intended.
Affected code
packages/core/src/tools/shell.ts:750-764:
for (const line of backgroundPIDLines) {
if (!/^\d+$/.test(line)) {
if (
line.includes('sysmond service not found') ||
line.includes('Cannot get process list') ||
line.includes('sysmon request failed')
) {
continue;
}
debugLogger.error(`background pid output: ${line}`);
// <-- missing continue
}
const pid = Number(line);
if (pid !== result.pid) {
backgroundPIDs.push(pid); // NaN !== result.pid is always true
}
}
How can this be reproduced?
Background a command whose pid-file capture includes any stray text line (partial write, shell warning). The resulting llmContent contains e.g. Background PIDs: 12345, NaN.
What did you expect to happen?
Unrecognized non-numeric lines are logged once and skipped; only valid PIDs reach backgroundPIDs.
Impact
Garbage data handed back to the model in tool results (confuses downstream reasoning), plus misleading error logs.
Suggested direction
Add continue; after debugLogger.error(...), or restructure as an early-validation loop.
Found by source audit on current main (commit 5411f113c); platform-independent. No open issue/PR covering this was found (searched: background PID NaN).
- Dominant language
- TypeScript
- Stars
- 107k
- Forks
- 14.6k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 43
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google-gemini/gemini-cli
-
bug(core): explicit `--model gemini-3-pro-preview` silently rewritten to `gemini-3.1-pro-preview` Openarea/agent effort/medium kind/bug priority/p2 status/bot-triaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
google-gemini/gemini-cli#29417 · 1 comment ·
-
area/enterprise kind/bug priority/p2 status/bot-triaged
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
google-gemini/gemini-cli#29406 ·
-
area/agent status/need-triage
Difficulty 2/5 Half a day Newbie friendliness 78/100
google-gemini/gemini-cli#29360 ·
-
area/agent kind/bug priority/p2 status/bot-triaged
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
google-gemini/gemini-cli#29315 ·
-
area/non-interactive effort/small kind/bug priority/p2 status/bot-triaged status/need-information
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
google-gemini/gemini-cli#29308 · 2 comments ·
All issues in google-gemini/gemini-cli
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100