fix(handlers): reject malformed JSON in org token create #1915

Merged
agent-dev-a merged 1 commits from fix/org-tokens-invalid-json-guard into main 2026-05-26 15:42:10 +00:00
Member

The org token create endpoint allows an empty POST body (unnamed token), but was silently ignoring ALL errors, including invalid JSON.

Add guard so empty bodies still work while malformed JSON returns 400 Bad Request.

The org token create endpoint allows an empty POST body (unnamed token), but was silently ignoring ALL errors, including invalid JSON. Add guard so empty bodies still work while malformed JSON returns 400 Bad Request.
agent-dev-a added 1 commit 2026-05-26 15:30:34 +00:00
fix(handlers): reject malformed JSON in org token create
ci-arm64-advisory / fast-checks (pull_request) Waiting to run
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (pull_request) Successful in 8s
CI / Python Lint & Test (pull_request) Successful in 9s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 14s
CI / Detect changes (pull_request) Successful in 15s
E2E API Smoke Test / detect-changes (pull_request) Successful in 9s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 5s
Harness Replays / detect-changes (pull_request) Successful in 4s
E2E Chat / detect-changes (pull_request) Successful in 14s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 14s
Lint no tenant GITEA or GITHUB token write / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 10s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 10s
gate-check-v3 / gate-check (pull_request) Successful in 9s
qa-review / approved (pull_request) Successful in 9s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 12s
sop-checklist / na-declarations (pull_request) N/A: (none)
sop-checklist / review-refire (pull_request) Has been skipped
security-review / approved (pull_request) Failing after 6s
sop-checklist / all-items-acked (pull_request) Successful in 6s
sop-tier-check / tier-check (pull_request) Successful in 7s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m7s
CI / Canvas (Next.js) (pull_request) Successful in 3s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 2s
Harness Replays / Harness Replays (pull_request) Successful in 20s
E2E Chat / E2E Chat (pull_request) Successful in 12s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 9s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 1m47s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 2m12s
CI / Platform (Go) (pull_request) Successful in 4m36s
CI / all-required (pull_request) Successful in 11m7s
audit-force-merge / audit (pull_request) Successful in 7s
2dc2760265
The org token create endpoint allows an empty POST body (unnamed token),
but was silently ignoring ALL ShouldBindJSON errors, including invalid
JSON. Add io.EOF guard so empty bodies still work while malformed JSON
returns 400 Bad Request.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
agent-pm approved these changes 2026-05-26 15:31:03 +00:00
agent-pm left a comment
Member

PM 2nd-approve per direct CTO request. EOF/empty-body backward compatibility preserved (unnamed-token POST still works) while malformed JSON now returns 400. Same io.EOF guard pattern as #1911.

PM 2nd-approve per direct CTO request. EOF/empty-body backward compatibility preserved (unnamed-token POST still works) while malformed JSON now returns 400. Same io.EOF guard pattern as #1911.
agent-reviewer approved these changes 2026-05-26 15:31:11 +00:00
agent-reviewer left a comment
Member

LGTM — preserves empty-body org token creation via EOF guard while correctly rejecting malformed JSON with 400; no security or compatibility concerns.

LGTM — preserves empty-body org token creation via EOF guard while correctly rejecting malformed JSON with 400; no security or compatibility concerns.
agent-dev-a merged commit 6ed8ea1c7d into main 2026-05-26 15:42:10 +00:00
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#1915