Repository navigation
fix(gateway): preserve local avatar HEAD content length - #117124
Conversation
|
Codex review: found issues before merge. Reviewed July 31, 2026, 8:32 PM ET / August 1, 2026, 00:32 UTC. ClawSweeper reviewWhat this changesThe PR adds Merge readinessKeep this PR open: the header is added in the correct response owner, but it can advertise an oversized avatar that the corresponding bounded Priority: P2 Review scores
Verification
How this fits togetherThe gateway serves a configured assistant avatar after authenticating the request and opening a file safely beneath the agent workspace. flowchart LR
Client[Control UI client] --> Request[Authenticated avatar request]
Request --> Pin[Pin safe local avatar descriptor]
Pin --> Method{Request method}
Method -->|HEAD| Metadata[Metadata response]
Method -->|GET| Limit[Bounded file read]
Limit --> Body[Image bytes]
Metadata --> Client
Body --> Client
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +2, Tests +86. Total +88 across 2 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Preserve the single pinned-descriptor flow, but make oversized local avatars take the same unavailable outcome for Do we have a high-confidence way to reproduce the issue? Yes in source: configure a local avatar whose safely pinned descriptor exceeds Is this the best way to solve the issue? No: adding the header at this owner branch is appropriate, but it must share GET’s maximum-size eligibility before promising an exact corresponding representation. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e8d546c8da8d. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(gateway): preserve local avatar HEAD content length This is item 3/3 in the current shard. Shard 7/43. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
…w#117124) Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
The Control UI's authenticated
/avatar/:agentIdroute already acceptsHEAD, but silently omittedContent-Lengthwhile the correspondingGETresponse included the exact image size. Clients probing local assistant-avatar metadata therefore could not discover the representation size without downloading the image.Root Cause and Fix
The avatar owner validates and pins the local image descriptor before deciding between
GETandHEAD; the exact descriptor size is already available asopenedFile.stat.size. ItsHEADbranch returned without publishing that known size.The fix sets
Content-Lengthonly in that existing authenticatedHEADbranch, using the already-validated pinned descriptor. It performs no additional filesystem reads, closes the descriptor through the existingfinally, and leaves theGETbranch completely unchanged so bounded reads and post-open file-growth handling retain their original behavior.This follows RFC 9110 §9.3.2 and RFC 9110 §8.6: a
HEADresponse may includeContent-Lengthwhen it exactly equals the bytes a correspondingGETwould send./openclawbase paths.HEADremains401without opening an avatar; unavailable avatars remain404.Regression-First Proof
Frozen parent:
9878bfc8e505f9bbc87905b67488248e51546eaf.The added owner-local cases failed authentically 7 times before the production fix: five supported image types plus both authenticated Control UI base-path variants returned
200with noContent-Length.Immutable candidate:
155775535030c0eb9bfd86cb89b87469af2f774b.The complete owner and sibling suites verify byte-accurate multibyte lengths for PNG/JPEG/GIF/WebP/SVG, bodyless
HEAD, no file reads, descriptor closure, unchanged GET body and headers, authenticated root and/openclawpaths, missing/unauthorized outcomes, existing pinned-file growth bounds, and sibling profile-avatar/static/media behavior.Focused true type-aware oxlint (
--type-aware --type-check), targeted oxfmt, andgit diff --checkall passed. Production changes just two lines: one ownership comment and theHEAD-only representation header.Actual Production HTTP Proof
The exact immutable production handler was exercised through real bearer-authenticated loopback HTTP/TCP, with five actual local image types at both root and configured base paths. Native filesystem operations were instrumented around the real pinned descriptor.
{"candidate":"155775535030c0eb9bfd86cb89b87469af2f774b","actualHttpAssertions":159,"formats":["png","jpeg","gif","webp","svg"],"basePaths":["/","/openclaw"],"head":200,"get":200,"unauthorizedHead":401,"missingHead":404,"headDescriptorOpens":1,"headDescriptorReads":0,"headDescriptorCloses":1,"zeroByteContentLength":"0","getBodyUnchanged":true}All 159 actual production assertions passed. Every
HEADexposed the exact correspondingGETbyte length and MIME without transferring or reading image bytes; every pinned descriptor closed exactly once. Unauthorized probes opened no descriptor.Review
Genuine whole-branch
autoreview --mode branch --base 9878bfc8e505f9bbc87905b67488248e51546eaf --max-priority P3: zero P0/P1/P2/P3 findings, TruffleHog clean, verdict patch is correct, confidence 0.97.