Skip to content

fix(http): avoid retrying keyless writes (#103)#256

Open
naufalfx805-source wants to merge 1 commit into
TestSprite:mainfrom
naufalfx805-source:fix/retry-idempotency-guard
Open

fix(http): avoid retrying keyless writes (#103)#256
naufalfx805-source wants to merge 1 commit into
TestSprite:mainfrom
naufalfx805-source:fix/retry-idempotency-guard

Conversation

@naufalfx805-source

@naufalfx805-source naufalfx805-source commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Closes #103.

This gates transport-level retries so non-idempotent writes without an Idempotency-Key are not blindly replayed after a network error or bare edge 408/502/504 response.

Changes:

  • Allows transport retries for GET/HEAD requests.
  • Allows transport retries for writes only when an Idempotency-Key header is present, case-insensitively.
  • Leaves API-envelope retry behavior unchanged.
  • Adds regression tests for keyless POST vs idempotency-key POST on both thrown transport errors and bare 502 edge responses.

Verification

  • npm test -- src/lib/http.test.ts -> 45 passed
  • npm run lint
  • npm run typecheck
  • npm run build
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes
    • Improved retry handling for network failures and transient gateway responses.
    • Prevented automatic retries for non-idempotent requests unless an idempotency key is provided.
    • Continued supporting retries for safe requests and idempotent-keyed writes.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 256a78a0-e5c0-43d6-ae9b-554f4848e6ff

📥 Commits

Reviewing files that changed from the base of the PR and between 60d55e4 and 674e8e2.

📒 Files selected for processing (2)
  • src/lib/http.test.ts
  • src/lib/http.ts

Walkthrough

HttpClient now limits transport retries to idempotent methods or requests with an idempotency key. Tests cover keyless and keyed POST requests for thrown fetch errors and transport-edge responses.

Changes

Transport retry policy

Layer / File(s) Summary
Retry eligibility and transport-path gating
src/lib/http.ts
Transport retries are allowed for GET/HEAD requests or requests containing an idempotency-key header, and are suppressed for other requests in both transport failure paths.
Write retry behavior tests
src/lib/http.test.ts
POST tests verify that keyless writes are not retried while idempotency-key writes retry for fetch errors and 502-like transport-edge responses.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: ruili-testsprite, zeshi-du

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the key change: preventing retries of keyless writes.
Linked Issues check ✅ Passed The code and tests match #103 by blocking transport retries for keyless writes while preserving retries for GET/HEAD and keyed writes.
Out of Scope Changes check ✅ Passed The changes stay focused on HTTP retry behavior and regression tests, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Hackathon] Transport retries replay non-idempotent writes with no idempotency key

1 participant