Repository navigation
Description
Summary
The lab-ops-hub container crawler (pkgs/lab-ops-hub/container/app.py) reads its
POST /crawl request body with no validation of Content-Length and no read
bound, on a single-threaded server. A negative or oversized declared length
wedges the whole crawler service in rfile.read() until the client socket
closes — every other crawl (and the health GET /) starves behind it.
Evidence (verified this run, laptop @08dd577848)
pkgs/lab-ops-hub/container/app.py, Handler.do_POST (:1473-1478):
length = int(self.headers.get("content-length", "0"))
url = json.loads(self.rfile.read(length))["url"]served by the single-threaded server at :1507-1508:
HTTPServer(("0.0.0.0", 8080), Handler).serve_forever()Content-Length: -1→rfile.read(-1)reads until EOF: as long as the
client holds the socket open, the handler never returns.Content-Length: 10000000with a small body actually sent →read()blocks
awaiting bytes that never arrive.- There is no cap and no socket deadline on this read. The response side of
the same file is carefully bounded by contrast:_fetch_crawlcaps the
fetched body at_CRAWL_MAX_BODY_BYTES = 2_000_000(:1358) under one
absolute 20 s deadline (_CRAWL_TIMEOUT_SECONDS, :1357, :1362-1367),
explicitly so "a peer that keeps dribbling bytes cannot renew the budget".
The request side has neither protection. - Secondary: a non-numeric
Content-LengthraisesValueErrorout of
int(...)and is answered by the catch-all as 502 (a container
failure), not 400 — and per the lab-ops-hub: POST /api/crawl shape-trusts the container crawler response — JSON null 500s after the R2 archive write, a JSON string silently stores an all-null crawls row, wrong-typed fields bind as-is #7018 contract a 502 is what makes the
Worker treat the crawl as a container failure and fall back, so a client
error is indistinguishable from a dead crawler.
Reproduction (probe, real module, validation/fetch stubbed — the read loop is what is under test)
Probe: ~/git/fleet/probe-labops-bodyread/probe.py on the laptop (real
app.py Handler over a real socket; validate_crawl_url/_fetch_crawl
stubbed, idna stubbed as the sandbox python lacks it):
- Control
POST /crawlwith a well-formed length →200; controlGET /→200. POST /crawlwithContent-Length: -1, partial body, socket held open →
no response within 3 s; a concurrentGET /on a new connection also gets
no response within 3 s (the single-threaded server is wedged); after the
client socket closes (EOF),GET /answers200again.POST /crawlwithContent-Length: 10000000and a partial body, socket
held open → same wedge and same starvation of the concurrentGET /.
Why it matters
The container is a separate service with its own release cadence (the premise
of #7018); the hub Worker is its only caller today and sends well-formed
lengths, but any client bug, proxy quirk, or future caller that stalls a body
mid-request takes the crawler out for every subsequent crawl until the
connection dies — there is no server-side deadline that releases it, and the
container's sleepAfter idle shutdown never engages while a handler is stuck
in a read. It is the one unbounded input left in a file that otherwise bounds
every byte and second it spends.
Acceptance criteria
-
do_POSTvalidatesContent-Lengthbefore reading: a missing,
non-integer, negative, or over-cap value is rejected with a 400 JSON
error without reading the body (the cap should be sized for the actual
payload — a{"url": ...}JSON object — and named as a constant, in
the style of_CRAWL_MAX_BODY_BYTES). - The body read itself is bounded: the handler cannot block indefinitely
on a client that declares an in-cap length but never finishes sending
(e.g. a socket/read deadline consistent with the crawl deadline
machinery), and the server answers other requests afterwards. - Malformed-length requests are answered 400, not the catch-all 502, so
client errors stay distinguishable from container failures. - Regression coverage in the container test suite
(pkgs/lab-ops-hub/test/test_container_validate.pyor a sibling):
negative length, oversized declared length with a partial body, and
non-numeric length each get a prompt 400 and the server still answers
a followingGET /; the well-formed control still returns 200. - Existing container + worker suites still pass.
Related: #7018 (the Worker-side shape validation of this container's
responses), #6975 (the hub's POST bind validation). This issue covers the
container's request side, which neither touched.
Activity
developing-today commentedon Nov 8, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 10, 2026
agent-note:v1
task: 11478
lane: code-j
stage: handed_off
Execution lane is opencode (lane row 3671). Handed off to the opencode claimant; lane code-j parks task 11478 for the claimant. Issue #7036 revalidated OPEN with no hard-stop labels 2026-11-10T00:48Z.
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
3 remaining items
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 10, 2026
Lane code-o picked up task 11478 (issue #7036) — handed off to opencode claimant.
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 10, 2026
🤖 Agent note · done (bookkeeping, §1c)
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
opencode(lane row 3671, session_id null).dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off (task 11478, lane code-u)
Merge pull request #8705 from developing-today/queue/11478-7036-crawl…
dezren39 commentedon Nov 11, 2026
Agent note — task 11478 done (fixed_merged)