fix: make HTTP body capture completion-aware - #800
Conversation
|
🚀 Preview deployed: https://demo.clawpatrol.dev/pr-preview/pr-800/ Built from |
Avocet review statusState: Completed The formal GitHub review is the authoritative result. This comment only reports operational status. |
avocet-bot
left a comment
There was a problem hiding this comment.
Review model: Claude Opus
Reviewed base: b2a84fae0ec02bb1ec3ee7bf28f8487dfe8ad5d6
Reviewed commit: fcf9cf50156f188f6fe58e14697522a8806b08d8
Current PR base: e0350a79a20197f0fba894080f4ecad8a1950e7a
Current PR head: ee5ea9e915ad6c8cc32bdb8f60f53c9324b8e633
Verdict for the reviewed commit: APPROVE (informational only)
This review applies only to the reviewed comparison above.
Newer commits and their integration with the current base were not reviewed.
Re-request review to review the current PR revision.
No blocking findings. The body-capture lifecycle feature is correct, cohesive, and thoroughly tested.
Verified in depth:
- SQL column/placeholder/value counts balance across
Sink.drain(29),loadAction(28),readTailEvents(25), anddev_seed.go(25);req_transformedcorrectly relies on itsDEFAULT 0where omitted. - Migrations 0020/0021 are sound — 0020 omits an explicit
_schemainsert but the migrate runner's catch-all (db.go:132) records the version, so ordering and idempotency hold. - The mutex-guarded sampler state machine keeps
abortedterminal, gates SHA tocomplete && n>0, and fails closed on short-EOF, read-error, close-before-EOF, and content-length overrun. Read errors inbufferHTTPBodyForMatchResultnow surfacetruncated=true+readErrinstead of the previous fail-opennil,false. validateHTTPFixtureBodyCapturerejects every unfaithful capture (incomplete/aborted/legacy-unknown/truncated/content-encoded/binary/decoded-truncated/redacted/transformed/non-UTF8); happy path and each rejection branch are covered.
Non-blocking suggestions:
- web.go:3086 —
captureState()'sdefaultmaps unknown states tocomplete(fail-open). If a fourthsamplerStateis ever added, prefer an exhaustive switch defaulting toincompleteto stay consistent with the PR's fail-closed intent. - web.go:3010 — the
bodyTruncatedMarkerdoc points toHttpBodyfor marker stripping, but that logic moved tosplitBodyCapturein dashboard/src/lib/bodyCapture.ts; update the cross-reference.
Summary
Why
An early response could snapshot a body while it was still being written. Fixture export could also treat a partial or changed body as the original request.
Tests
go test ./...