Repository navigation
fix: guard CLAUDE_CODE_MAX_RETRIES against non-numeric env values #2172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,3 +16,5 @@ package-lock.json | |
| coverage/ | ||
| agent.log | ||
| plan/ | ||
|
|
||
| .idea/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -808,7 +808,14 @@ function shouldRetry(error: APIError): boolean { | |
|
|
||
| export function getDefaultMaxRetries(): number { | ||
| if (process.env.CLAUDE_CODE_MAX_RETRIES) { | ||
| return parseInt(process.env.CLAUDE_CODE_MAX_RETRIES, 10) | ||
| const raw = process.env.CLAUDE_CODE_MAX_RETRIES.trim() | ||
| const parsed = Number(raw) | ||
| if (!Number.isNaN(parsed) && parsed >= 0 && Number.isInteger(parsed)) { | ||
| return parsed | ||
|
Comment on lines
+811
to
+814
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
sed -n '785,830p' src/services/api/withRetry.ts
printf '\n--- references ---\n'
rg -n "CLAUDE_CODE_MAX_RETRIES|DEFAULT_MAX_RETRIES" src/services/api src -g '*.{ts,tsx}' | head -80Repository: Gitlawb/openclaude Length of output: 6633 🏁 Script executed: #!/bin/bash
sed -n '1,40p' src/services/api/withRetry.test.ts
sed -n '185,245p' src/services/api/withRetry.test.tsRepository: Gitlawb/openclaude Length of output: 3176 Reject whitespace-only retry values. When 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| } | ||
| logForDebugging( | ||
| `Invalid CLAUDE_CODE_MAX_RETRIES="${raw}", falling back to default (${DEFAULT_MAX_RETRIES})`, | ||
| ) | ||
| } | ||
| return DEFAULT_MAX_RETRIES | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Clear inherited environment state before each test.
afterEachruns only after a test. IfCLAUDE_CODE_MAX_RETRIESis set when the test file starts, the first test imports that value and can fail instead of testing the default path.Delete the variable in
beforeEach, and restore the original value inafterEachif other tests depend on it.As per path instructions, isolate global/env/config state in tests.
🤖 Prompt for AI Agents
Source: Path instructions