Skip to content

refactor(agent): avoid unsafe HTTP retries - #20456

Merged
yuzhichang merged 1 commit into
infiniflow:mainfrom
6ba3i:refactor/agent-http-retry-h1
Sep 30, 2026
Merged

yuzhichang merged 1 commit into
infiniflow:mainfrom
6ba3i:refactor/agent-http-retry-h1

Conversation

@6ba3i

@6ba3i 6ba3i commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

HTTP retries could repeat POST requests after a server or network failure. This change retries only idempotent methods while keeping explicit service retries intact.

Constraint: Preserve existing idempotent retry behavior and explicit service retries.
Rejected: Retrying every method | POST may have completed before the transport reports failure.
Confidence: high
Scope-risk: narrow
Directive: Keep automatic retries limited to methods safe to replay.
Tested: HTTPHelper tests, race tests, build, Compose, live component-debug POST.
Not-tested: GPU runtime.
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 1522c76c-a4ff-4221-8272-3f670a51ce8a

📥 Commits

Reviewing files that changed from the base of the PR and between eb100d1 and 7a2e866.

📒 Files selected for processing (3)
  • internal/agent/tool/http_helper.go
  • internal/agent/tool/http_helper_test.go
  • internal/agent/tool/querit_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

HTTPHelper retries network errors and 5xx responses only for GET, HEAD, OPTIONS, TRACE, PUT, and DELETE. POST requests return after one attempt. Pinned requests use a cloned transport with keep-alives disabled. Tests check retry counts and pinned connection closure.

Changes

HTTP helper behavior

Layer / File(s) Summary
Method-specific retry handling
internal/agent/tool/http_helper.go, internal/agent/tool/http_helper_test.go, internal/agent/tool/querit_test.go
Retry eligibility now depends on the HTTP method. Tests check that POST requests are not retried and update expected request counts for network errors and 500 responses. The test for a temporary 503 succeeding after retries was removed.
Pinned transport connection handling
internal/agent/tool/http_helper.go, internal/agent/tool/http_helper_test.go
The cloned transport for pinned requests disables keep-alives. A test checks that the connection closes after the response body is consumed and closed.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: jinhai-cn

Merge Risk: ⚪ Minimal · up to 7a2e8

The change prevents automatic POST replay while retaining retries for eligible methods and closing pinned connections. No actionable merge-blocking risk is identified; merge after normal checks pass.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 7a2e8

The change reduces accidental request replay and closes otherwise unused pinned connections. No introduced security weakness was identified in the examined paths, but compatibility across all callers and deployment configurations was not established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated effect is on outbound requests using the shared helper, including Querit. Preventing another POST attempt after the server has received its body reduces one source of duplicated remote actions. The evidence does not establish every caller, tenant, asset, or deployment affected by this shared behavior.

Trust Boundaries and Controls

  • observed — The existing pinning controls remain: DoPinned requires a host and IP, checks that the URL hostname matches the supplied host, disables proxy use, and rewrites the dial destination to the pinned IP while preserving the logical hostname for TLS identity. The diff does not modify those controls.
  • observed — Querit's existing credential and error controls remain unchanged: credentials come from configured defaults or the environment, non-success upstream bodies are discarded, and supplied API keys are redacted from soft errors. Tests cover both configured and environment-sourced secrets.

Resilience and Maintainability Implications

  • inferred — Disabling keep-alives avoids retaining idle connections in a transport created for one pinned call. It does not remove the existing requirement to close returned response bodies, so the new test supports cleanup after proper caller termination rather than protection against body leaks.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly states the problem and the intended solution: avoid unsafe retries of POST requests while preserving explicit service retries. It omits the required "### Summary" heading, but …
Title check ✅ Passed The title clearly identifies the refactor and its purpose: preventing unsafe HTTP retries. It is concise and directly matches the main changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI

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

A rabbit checks each request in flight
POST takes one hop, then rests for the night
Safe methods may try again
Pinned links close when bodies end
Soft paws applaud the tests at dawn

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

@6ba3i
6ba3i requested a review from wangq8 September 30, 2026 09:30
@6ba3i 6ba3i added the ci Continue Integration label Sep 30, 2026
@6ba3i
6ba3i requested a review from yuzhichang September 30, 2026 10:43
@yuzhichang
yuzhichang merged commit b754c76 into infiniflow:main Sep 30, 2026
6 checks passed
@6ba3i
6ba3i deleted the refactor/agent-http-retry-h1 branch October 14, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants