#normalizeRetries silently coerces invalid maxRetries to 2 (e.g. -1 / 1.5 / 0)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 79/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- backend-api-design
Research direction
Start in src/client.ts at #normalizeRetries and inspect how client defaults and per request retry accounting use it. Read the existing retry validation tests, if present, and run the relevant client tests. Done means invalid values such as -1, 1.5, and "0" are rejected while undefined still defaults to 2 and 0 remains valid.
Written by the indexing model from the issue text.
Description
Summary
OpenAI silently coerces invalid maxRetries values to the default 2 instead of rejecting them. Callers that pass a typo / wrong type / non-integer (e.g. -1, 1.5, "0") get retries they did not ask for, with no throw and no warning.
Measured behavior
#normalizeRetries in src/client.ts:
#normalizeRetries(value: unknown): number {
return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : 2;
}
That path is used both for the client default (this.maxRetries = this.#normalizeRetries(options.maxRetries)) and per-request retry accounting.
| input | result today | what callers likely meant |
|---|---|---|
0 |
0 (correct) |
disable retries |
2 |
2 (correct) |
default |
-1 |
2 |
invalid / “no retries” in some APIs |
1.5 |
2 |
typo / bad config parse |
"0" |
2 |
stringified config that looks like “off” |
undefined |
2 |
default — fine |
So "0" and -1 both quietly enable two retries.
Comparison
Sibling SDKs fail closed on the same class of input:
@ai-sdk/*/ Vercel AI:prepareRetriesvalidates the parameter and throws on invalid values@anthropic-ai/sdk:validatePositiveInteger('maxRetries', …)rejects non-integers
Expected
Invalid maxRetries should throw (or at least warn) at client construction / request time, matching the documented contract that maxRetries is a non-negative integer configuration knob — not a soft hint that falls back to 2.
Suggested fix
Reject anything that is not a safe non-negative integer (same shape as Anthropic’s validatePositiveInteger), and keep undefined → default 2.
Happy to open a PR with a small unit test matrix for the cases above if maintainers want that direction.
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.6k
- Avg merge
- 12h 40m
- Merged PRs (30d)
- 204
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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 openai/openai-node
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
openai/openai-node#3080 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
openai/openai-node#3077 ·
Maintainers usually reply within 1 day
-
Split custom-code bootstrap tests into independently runnable casesPossibly taken @jbeckwith-oai claimed this 11 days ago. Open
openai/openai-node#3058 · 1 assignee ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 54/100
openai/openai-node#3050 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
openai/openai-node#2962 · 1 comment ·
Maintainers usually reply within 1 day
All issues in openai/openai-node
Similar issues
-
bug needs-triage potential-regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
aws/aws-sdk-js-v3#8408 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
colinhacks/zod#6743 ·
Maintainers usually reply within 1 day
-
[BUG] Packing list: the weight field drops digits on a slow connection and saves the wrong weightOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
anthropics/anthropic-sdk-typescript#1296 ·
Maintainers usually reply within 8 days
-
fix(docs): align git__gh troubleshooting with its actual failure pathsPossibly taken @akhil9tiet claimed this today. Openbug docs p2
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
vercel/eve#6130 · 2 comments ·
Maintainers usually reply within 1 day