Skip to content

fix(agent): stop polling expired webhook traces - #20619

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
T1mn:fix/go-webhook-expired-trace-polling
Oct 9, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
T1mn:fix/go-webhook-expired-trace-polling

Conversation

@T1mn

@T1mn T1mn commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #18815 and #19087 in the Go webhook trace path. This is independent of the request-reading fix in #20618.

After a client has selected a webhook_id, the trace key can expire while polling is paused. The empty-store branch currently returns webhook_id=null and finished=false, so the client keeps polling. A missing run in a non-empty store already ends polling.

Treat a missing store the same way as a missing selected run: preserve the ID and cursor, return an empty event list, and set finished=true. Polling without a selected run still waits for a trigger. No execution-success event is synthesized; the existing UI requires an explicit successful terminal event to show success.

Adds table-driven polling tests and a handler test that expires the key after discovery and checks repeated polls.

Validation

  • File-scoped tests of agent_webhook_trace.go and agent_webhook_trace_poll_test.go pass with -race on Go 1.26.6: seven cases. The two missing/blank selected-trace cases fail before the fix.
  • gofmt and git diff --check pass.
  • Full handler tests, including the new cache-expiry test, are not verified locally. bash build.sh --test ./internal/handler/... -run 'TestPollWebhookTrace|TestGetAgentWebhookLogs' -count=1 stops because the native DeepDoc backend does not support macOS. Linux CI is still needed.

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: 77413e78-cfc9-44e1-95d0-58fee985591e
📥 Commits

Reviewing files that changed from the base of the PR and between ef150bc and 292b957.

📒 Files selected for processing (3)
  • internal/handler/agent_webhook_trace.go
  • internal/handler/agent_webhook_trace_poll_test.go
  • internal/handler/agent_webhook_trace_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

pollWebhookTrace now continues when stored trace data is empty. Tests cover polling with missing or blank data, selected-run states, and a trace that expires between polls.

Changes

Webhook Trace Polling

Layer / File(s) Summary
Empty trace handling and polling tests
internal/handler/agent_webhook_trace.go, internal/handler/agent_webhook_trace_poll_test.go, internal/handler/agent_webhook_trace_test.go
Empty stored data skips JSON decoding and proceeds to run selection or webhook-ID validation. Tests check empty and non-empty selected-run outcomes, plus repeated polls after a trace expires.

Priority: ➖ Normal

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 292b9

The missing-trace behavior has targeted test coverage, and no actionable issue remains before merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: stopping polling for expired webhook traces.
Description check ✅ Passed The description includes the required Summary section, explains the problem and intended behavior, and provides relevant validation details 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 3 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 polls the quiet trace,
With empty logs, it keeps its place.
The cursor stays; no events appear,
An expired key brings completion near.
Two polls return, their answers clear.

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 merged commit b88e35b into infiniflow:main Oct 9, 2026
6 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