Skip to content

fix(agent): reject webhook body read failures - #20618

Merged
JinHai-CN merged 2 commits into
infiniflow:mainfrom
T1mn:fix/go-webhook-body-read-errors
Oct 9, 2026
Merged

JinHai-CN merged 2 commits into
infiniflow:mainfrom
T1mn:fix/go-webhook-body-read-errors

Conversation

@T1mn

@T1mn T1mn commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #18758 and #19089: those changes handle webhook execution failures and interrupted traces; this change rejects incomplete requests before the Agent starts, in the current Go backend.

parseWebhookRequest ignores body read and form parsing errors. For an unknown-length request, MaxBytesReader can report an exceeded limit while the handler still proceeds with a partial or empty payload. A valid JSON prefix followed by a read failure can also be accepted.

  • Return read and form parsing errors through the existing data-error envelope before dispatch.
  • Share the JSON body-reading path without changing JSON decoding behavior.
  • Replace the size-limit test that only reached the Content-Length check with unknown-length request tests. Cover both execution modes and trigger routes, interrupted reads, and bodies exactly at the configured limit.

Validation

  • In an isolated Go 1.26.6 / Gin 1.12.0 harness using the extracted production parser and parser tests, all six read-error cases failed before the fix. After the fix, those six cases and three exact-limit cases pass with the race detector.
  • gofmt and git diff --check pass.
  • Full handler-package validation is not yet verified locally: bash build.sh --test ./internal/handler/... -run 'TestWebhook|TestParseWebhookRequest' -count=1 is blocked by native dependency setup on macOS. The isolated parser check does not cover the handler dispatch tests or replace Linux CI.

Thank you for reviewing.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: 54f7281f-ff5c-4c31-8b98-f8a377a3f385
📥 Commits

Reviewing files that changed from the base of the PR and between a24fd33 and be967b0.

📒 Files selected for processing (1)
  • internal/handler/agent_webhook_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/handler/agent_webhook_test.go

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


📝 Walkthrough

Walkthrough

Webhook request parsing now returns form parsing and body read errors. Tests cover oversized and interrupted reads, confirm failed requests do not start the Agent, and verify that bodies at the 1000-byte limit are accepted.

Changes

Webhook Request Read Errors

Layer / File(s) Summary
Propagate request parsing errors
internal/handler/agent_webhook.go, internal/handler/agent_webhook_test.go
Form parsing and body read failures now return errors. Parser tests check read-error categories and successful parsing at the 1000-byte limit.
Verify webhook error handling
internal/handler/agent_webhook_test.go
Tests check that failed reads across content types, execution modes, and webhook paths return data-error envelopes without starting the Agent. The fake loader counts calls atomically.

Priority: ➖ Normal

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to be967

Interrupted JSON requests are rejected without starting the Agent. No issue requiring a fix before merge was identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: rejecting webhook body read failures before Agent dispatch.
Description check ✅ Passed The description includes the required Summary section, explains the problem and intended fix, and documents validation results and limitations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files.
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.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 the webhook stream,
And catches errors midstream.
No Agent starts when reads fail,
The parser leaves no partial trail.
At one thousand bytes, all formats pass,
Then hops away across the grass.

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

@JinHai-CN JinHai-CN added the ci Continue Integration label Oct 9, 2026
@JinHai-CN JinHai-CN self-assigned this Oct 9, 2026
@JinHai-CN
JinHai-CN merged commit 3d70338 into infiniflow:main Oct 9, 2026
11 checks passed
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