GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lab-ops-hub: POST /api/machines|notes|tasks return 500 (raw SQLite/SyntaxError text) for missing fields and non-JSON bodies — never a 400 · Issue #2480 · developing-today/code

lab-ops-hub: POST /api/machines|notes|tasks return 500 (raw SQLite/SyntaxError text) for missing fields and non-JSON bodies — never a 400 #2480

New issue
Copy link
New issue
Copy link
Closed
#3098
Closed
lab-ops-hub: POST /api/machines|notes|tasks return 500 (raw SQLite/SyntaxError text) for missing fields and non-JSON bodies — never a 400#2480
#3098
Copy link
Assignees
dezren39
Labels
app/lab-ops-hubPackage/app: lab-ops-hub (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Description

@dezren39
dezren39
opened on Oct 30, 2026
Issue body actions

Bug: lab-ops-hub POST routes return 500 for client-bad input — missing required fields and non-JSON bodies are never a 400

In pkgs/lab-ops-hub/src/index.ts, every JSON POST handler parses and binds the request body with no presence/type validation, inside the Worker's single outer try/catch that converts every throw into 500 {error: String(e)}:

  • POST /api/machines: const b = await req.json() then .bind(b.name, b.role ?? "compute", …) — optional fields get ?? defaults, but name is passed through raw. schema.sql declares machines.name TEXT NOT NULL UNIQUE.
  • POST /api/notes: .bind(b.title, b.body, b.tags ?? "") — notes.title and notes.body are both NOT NULL.
  • POST /api/tasks: .bind(b.title, …) — tasks.title is NOT NULL.
  • All of them (plus POST /api/crawl): a body that is not valid JSON makes await req.json() throw a SyntaxError, which lands in the same outer catch.

So POST /api/machines with {}, POST /api/notes with {"title":"x"} (no body), POST /api/tasks with {}, or any of these routes with a malformed-JSON body all return 500 with a raw SQLiteError: NOT NULL constraint failed… / SyntaxError: … string instead of a 400 naming the missing field. The handlers already know the intended contract — POST /api/crawl returns 400 {error: "url required"} when b.url is absent, and POST /api/files returns 400 when the multipart field is missing — the D1-backed routes just never got the same check.

Verified this run (main 5a34fa70)

Sandbox Bun probe replaying the handlers' exact INSERT statements and column definitions from schema.sql against bun:sqlite (hidden_files/probe-2026-10-29-laneB-uploadkey/probe2.ts in the keep-the-four-repos-healthy goal workspace):

  • machines insert with a null name → SQLiteError: NOT NULL constraint failed: machines.name
  • notes insert with null title/body → SQLiteError: NOT NULL constraint failed: notes.title
  • tasks insert with a null title → SQLiteError: NOT NULL constraint failed: tasks.title
  • JSON.parse of a malformed body → SyntaxError (the req.json() failure mode; no handler catches it locally, so the outer catch's 500 is the only possible response)

(In the Worker, an absent JSON key arrives at .bind() as undefined, which D1 either rejects at bind time or stores as NULL — both paths throw inside the same try and surface as the same 500; there is no code path that returns 400 for a missing required field.)

Why it matters

A 500 tells the dashboard (and any scripted caller) "the server broke" for what is actually "your request is missing name" — it misdirects debugging toward the deployment, leaks raw SQLite error text as the API contract, and makes client-side form validation impossible to test against a stable response. It is also inconsistent with the two routes in the same file that do validate (/api/crawl, /api/files).

Acceptance criteria

  • POST /api/machines|notes|tasks with a missing/empty required field (name; title/body; title) returns 400 with an error naming the field; valid requests unchanged (201 + id).
  • A non-JSON body on any JSON POST route returns 400, not 500.
  • No raw SQLite/SyntaxError text in 400 responses; genuine server failures still 500.
  • Regression coverage for the 400 cases (the validation helper, if factored into src/lib.ts per the lab-ops-hub: the #500 crawl-timeout fix has no regression test — crawlFallback's fetcher is inline in the untestable Worker entry #524 pattern, is unit-tested there).

Dedup

gh searches (open + closed) for lab-ops-hub + 400/validation/missing/malformed return only crawler-validator issues (#502 etc.) — nothing covers the D1 POST routes' input validation.

— filed by new-issue-creator-code-b (Lane B), 2026-10-29 run

Activity

Next
  1. developing-today commented on Oct 30, 2026

    @developing-today
    developing-todayBot
    on Oct 30, 2026 – with developing.today
    Contributor
    More actions

    CODE-1267

  2. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/lowNice to have; do when convenient
    queue/queuedHas a queued queue task
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    status/needs-triageNot yet triaged; needs a first look
    app/lab-ops-hubPackage/app: lab-ops-hub (pkgs/ or apps/ in this repo)
    effort/xsTrivial: expected under 30 minutes of work
    on Oct 30, 2026
  3. dezren39 commented on Oct 30, 2026

    @dezren39
    dezren39
    on Oct 30, 2026
    MemberAuthor
    More actions

    🤖 Agent note · filed

    • Agent: new-issue-creator job (Lane B, slug new-issue-creator-code-b)
    • Session / ID: cron job new-issue-creator-code-b, run 2026-10-30T00:36:09Z
    • Found via: filed this run
    • Task: Filed after verifying with a sandbox Bun probe (bun:sqlite replay of the handlers' exact INSERTs with schema.sql's NOT NULL columns; malformed-JSON SyntaxError has no local catch): the machines/notes/tasks POST routes return 500 with raw internal error text for missing required fields and non-JSON bodies, never a 400 — unlike /api/crawl and /api/files in the same file. Triage packet enqueued to repo-health-code-pilot.
    • Expectation: effort/xs — triage pins the validation shape (per-route checks vs a shared lib.ts helper) and the 400 error format, then routes a small_fix packet.
    • Links: packet packet-2480-triage.json (queue repo-health-code-pilot); evidence issue-code-labops-post-validation-body.md + probe-2026-10-29-laneB-uploadkey/probe2.ts in the goal's hidden_files
  4. github-actions
    assigned
    dezren39
    on Oct 30, 2026
  5. dezren39
    added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    status/needs-triageNot yet triaged; needs a first look
    queue/queuedHas a queued queue task
    on Oct 31, 2026
  6. 14 remaining items

  7. dezren39
    added
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    on Oct 31, 2026
  8. dezren39 commented on Oct 31, 2026

    @dezren39
    dezren39
    on Oct 31, 2026
    MemberAuthor
    More actions

    🤖 Agent note · parked

    • Agent: queue worker (repo-worker-code), lane C shift
    • Session / ID: queue task 4355
    • Found via: queue claim
    • Task: PR lab-ops-hub: validate JSON POST bodies (400, not 500) for #2480 #3098 opened @4679f006f implementing the lab-ops-hub: POST /api/machines|notes|tasks return 500 (raw SQLite/SyntaxError text) for missing fields and non-JSON bodies — never a 400 #2480 validation (lib.ts helpers + 4 routes wired, 6 new tests; laptop: TS 47/47, Python 63/63; tsc errors on touched files 16 on main → 1 pre-existing unrelated LiveRoom error). Codex review completed clean (no findings). Parked because no CI workflow runs have started yet for the head SHA (fleet CI backlog).
    • Expectation: on resume — lab-ops-hub CI green on PR lab-ops-hub: validate JSON POST bodies (400, not 500) for #2480 #3098 → merge → lab-ops-hub: POST /api/machines|notes|tasks return 500 (raw SQLite/SyntaxError text) for missing fields and non-JSON bodies — never a 400 #2480 closes → complete task as fixed_merged.
    • Links: PR lab-ops-hub: validate JSON POST bodies (400, not 500) for #2480 #3098 · branch queue/4355-2480-lab-ops-hub-validation · laptop worktree ~/git/fleet/4355-2480-lab-ops-hub-validation
  9. dezren39
    added
    queue/claimedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Oct 31, 2026
  10. dezren39 commented on Oct 31, 2026

    @dezren39
    dezren39
    on Oct 31, 2026
    MemberAuthor
    More actions

    agent-note:v1 — merging (queue task 4355, lane A resume)

    Resume verification on PR #3098 @4679f006f (exact head):

    • Codex review completed on this head: no findings, 0 review threads.
    • No PR-triggered lab-ops-hub run exists (dropped, CI: pushes to PR #2629 after opening created no workflow runs (synchronize events dropped) #2713) and lab-ops-hub.yml has no workflow_dispatch trigger, so CI could not be dispatched. Instead the workflow's own verification was run first-hand on the laptop worktree at the exact head: npm test in pkgs/lab-ops-hub (the single documented command the workflow runs) — EXIT 0, TypeScript suite pass + Python suite 63 tests OK.
    • The workflow runs on every push to main touching the package, so the merged tree gets its own completed verification run by design.
    • PR is MERGEABLE; no hard-stop labels.

    Merging under the standing rule (change verified sound on the exact head; CI absence is the known dropped-trigger infra pattern, not a red check).

  11. dezren39
    added a commit that references this issue on Oct 31, 2026

    lab-ops-hub: validate JSON POST bodies (400, not 500) for #2480 (#3098)

    ada2d88
  12. dezren39
    closed this as completedin #3098on Oct 31, 2026
  13. dezren39
    removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Oct 31, 2026
  14. dezren39 commented on Oct 31, 2026

    @dezren39
    dezren39
    on Oct 31, 2026
    MemberAuthor
    More actions

    agent-note:v1 — done (queue task 4355): PR #3098 merged ada2d88; issue auto-closed. Verification evidence in the merge note above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

Labels

app/lab-ops-hubPackage/app: lab-ops-hub (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.