Repository navigation
Guard the lanes seed routes against non-object JSON bodies - #997
Conversation
_handle_dtn_seed and _handle_staging_seed in serve_openxfactory_lanes.py called body.get(...) on whatever _read_json_body() returned without checking its shape. A JSON list, string, number or bool body parses fine but has no .get, so it raised AttributeError in the request thread and the client got no HTTP response at all; a malformed or empty body collapsed to the same _read_json_body() None sentinel and hit an early `return` with no response either. Both handlers now refuse a None or non-dict body with the same 400 invalid_body / JSON_OBJECT_BODY_REQUIRED payload _handle_refresh_action already uses in this file, so no accepted shape changes and no route in this module can leave a request hanging with no response. refs #768 Lane: openxfactory-2 Co-Authored-By: Claude Fable 5.1 <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]>
Reviewer's GuideThe PR hardens the loopback-gated DTN and staging seed handlers by requiring JSON object bodies and returning the established structured 400 error instead of hanging or raising on invalid input. New end-to-end tests cover all relevant non-object and malformed-body cases while confirming the existing happy paths remain intact. Sequence diagram for guarded seed route body validationsequenceDiagram
participant Client
participant SeedHandler
participant JSONReader
Client->>SeedHandler: _handle_dtn_seed() or _handle_staging_seed()
SeedHandler->>JSONReader: _read_json_body()
JSONReader-->>SeedHandler: body
alt body is None or not a dict
SeedHandler->>Client: _send_json(400, invalid_body, JSON_OBJECT_BODY_REQUIRED)
else body is a dict
SeedHandler->>SeedHandler: body.get(project_id)
SeedHandler-->>Client: Continue existing seed handling
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
🟢 Approval recommended
All reviewed changes are covered and no unresolved blocking issues were identified.
Pull request overview
This pull request makes the DTN and staging seed routes reject invalid JSON bodies with consistent 400 invalid_body responses.
Changes:
- Added object-body validation to both seed handlers.
- Added wire-level tests for malformed and non-object payloads.
File summaries
| File | Summary |
|---|---|
tests/ideation-dashboard/test_staging_seed.py |
Tests staging seed refusals. |
tests/ideation-dashboard/test_shared_identity.py |
Tests DTN seed refusals. |
scripts/ideation_dashboard/serve_openxfactory_lanes.py |
Validates seed request bodies. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 2 days and 2 hours by commenting @sourcery-ai review. Upgrade to get a review now.
|
Lane: openxfactory-2 (openXfactory-2) |
origin/main moved five commits ahead of this branch's fork point, three of which touch files this PR also declares edits on: - #995 (9e43f3d, ASK-7 window): four declared lines on the cli.py and serve.py rows of docs/opendox-carve-manifest.yaml, plus the four scripts/tests files that quote the running "862" declared-line total (carve_lines.py, validate-carve-manifest.py, verify-carve-arrival.py, tests/carve_manifest/test_carve_manifest.py). - #984 (a1ef886): carve tooling/admissions hardening unrelated to the five rows this PR touches. - #997, #996, #999: no overlap with this PR's files. Conflict resolution, keeping both sides: - docs/opendox-carve-manifest.yaml: the header comment block now carries the ASK-7 window's paragraph (landed first, 2026-09-11) ahead of the § 3.4 SLICE-S3 paragraph (2026-09-12), in landing order. The S3 paragraph's own arithmetic is untouched (it was already stated as a DELTA — "+40 over two rows" — precisely so a later-landing sibling act would not need to rewrite it); only its framing of the ASK-7 window changed from "is in flight" to "already moved the running total to 866", since this merge is the event that makes ASK-7's landing a fact rather than a future one. The four ASK-7 row edits (cli.py:834, serve.py:155/725/1338) and the two S3 row edits (app.js's 37 lines, test_bullseye_widget.py's 3 lines) are all kept. - scripts/carve_lines.py, scripts/validate-carve-manifest.py, scripts/verify-carve-arrival.py: each had a single docstring line citing the running declared-line total — "866" from main (ASK-7), "902" from this branch (which assumed the pre-ASK-7 base of 862). Corrected to 906 in all three: 866 (post-ASK-7) + 40 (this act's own delta) = 906, matching the pinned test assertion. - tests/carve_manifest/test_carve_manifest.py: merged both narrative additions to test_the_real_manifest_carries_the_ruled_q_l7_amendment in landing order (ASK-7 then S3), corrected the final aggregate assertion from this branch's stale (902, 151) to (906, 151), kept main's per-row pinned ASK-7 checks (cli_row/serve_row) verbatim, and fixed their comment's citation of the aggregate from (866, 150) to (906, 151) to match the corrected assert two lines above. Also fixed a second, non-conflicting docstring in test_the_line_count_is_exactly_the_expression_the_validator_carried that still read "902". A pre-existing defect, unrelated to the conflict, found while resolving: the test_bullseye_widget.py row's two edits (already on this branch's HEAD before any merge, commit 6843a25) had a blank line splicing them apart, which left the `adapter calls` edit's `note:` key duplicated with the `path constants` edit's original note — YAML silently keeps the last of a duplicate key, so the S3 note was silently discarded and the wrong note landed on the wrong edit. Confirmed with a duplicate-key-aware loader before and after. Fixed by restoring each edit's own note; a full-document duplicate-key scan afterward finds none remaining anywhere in the manifest. Verified after resolution: - python3 scripts/validate-carve-manifest.py: OK, 456 rows, 168 moved_verbatim / 150 moved_with_declared_edit / 138 not_moved. - python3 scripts/verify-carve-arrival.py --destination opendox_code --phase B against openDox-code PR #14's head (09b42f5b): DECLARED src/opendox/web/app.js, DECLARED tests/test_bullseye_widget.py, 0 refusals (three newly-created files admitted ad hoc for this local check only: src/opendox/view_extension.py, src/opendox/web/views/view_extension.js, tests/test_view_registry.py — the governed admissions-file entries for those belong to the pin-bump PR that follows #14's own landing, not this row-annotation PR). The one "unapplied" declared-edit row the summary counts is scripts/ideation_dashboard/doxbench_scope_types.py, an unrelated pre-existing row (successor #838, open at the carve) — not S3. - pytest tests/carve_arrival tests/carve_manifest tests/carve_conformance -q: 269 passed (121 + 110 + 38). Lane: openxfactory-4-opendox-extraction Refs #656 Co-Authored-By: Claude Sonnet 5 <[email protected]>



Lane: openxfactory-2 (openXfactory-2)
What:
_handle_dtn_seedand_handle_staging_seedinscripts/ideation_dashboard/serve_openxfactory_lanes.pynow refuse aNoneor non-dict parsed body with a clean400 invalid_body/JSON_OBJECT_BODY_REQUIREDpayload, instead of either raisingAttributeErroronbody.get(...)(a valid JSON list/string/number/boolbody) or silently
return-ing with no HTTP response at all (a malformedor empty body, which
_read_json_body()also collapses toNone).Why: pre-existing defect recorded on #768 (found by Copilot's review
of #761, confirmed pre-existing on
main): both routes are loopback-gatedhuman-console write routes, so the blast radius was the local console
hanging or crashing its own request thread rather than the hosted plane,
but a request that gets no response at all is still a bug worth a clean
refusal.
How: the single
if body is None: returnguard at each site isreplaced with
if body is None or not isinstance(body, dict):thatanswers
400with the sameinvalid_body/JSON_OBJECT_BODY_REQUIREDshape
_handle_refresh_actionalready uses a few lines below in this samefile — no new idiom, no accepted body shape changed.
Verified:
python3 -m pytest -q tests/ideation-dashboard/test_shared_identity.py tests/ideation-dashboard/test_staging_seed.py tests/ideation-dashboard/test_serve_column_split.py— 45 passedpython3 -m pytest -q tests -k 'lanes or serve_openxfactory or shared_identity or staging_seed'— 33 passed, 2 skippedpython3 scripts/doc-health.py --single-repo .— New regressions vs previous report: 0OPENSPEC_TELEMETRY=0 openspec validate --all --strict— Totals: 100 passed, 2 failed (same known pre-existing failures asorigin/main:disposition-codexfactory-declared-renames,disposition-codexfactory-floor-relocation-retitle)git diff origin/main --stat— only the server module and its two test filesrefs #768
🤖 Generated with Claude Code
Summary by Sourcery
Reject invalid JSON request bodies consistently on the DTN and staging seed routes.
Bug Fixes:
Tests: