Skip to content

fix(api): reject POST /api/endpoints without label or host#231

Merged
rado0x54 merged 1 commit into
developfrom
fix/endpoints-require-label-host
Jul 2, 2026
Merged

fix(api): reject POST /api/endpoints without label or host#231
rado0x54 merged 1 commit into
developfrom
fix/endpoints-require-label-host

Conversation

@rado0x54

@rado0x54 rado0x54 commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the last spec-vs-code drift found during the #225 parity work: POST /api/endpoints accepted a body with no label/host and still returned {status:"created"}, persisting a blank endpoint — even though openapi.yaml marks both as required and the MCP create path already enforces them.

Surfaced while writing the golden-http suite (#227): a {host}-only POST unexpectedly returned 200.

Change

src/server/routes/endpoints.ts — reject POST /api/endpoints with 400 { error: "label and host are required" } when either is missing or whitespace-only; the trimmed values are what get persisted. username still defaults to shellwatch, so only label/host are required — matching the spec's required: [label, host].

No OpenAPI change needed: the spec already declared these required and documents the 400, so this brings the code into line with the frozen contract (rather than the other way around).

Test

New golden err-400-endpoint-missing-fields characterizes the behavior (POST {host} → 400). Verified no existing test creates an endpoint without label/host, so nothing regressed.

Validation

  • pnpm test 323/323, pnpm test:integration 182/182, pnpm typecheck ✓, pnpm api:lint ✓, pnpm spdx:check ✓.

Follow-up to #225 (item-3 characterization finding #3). This closes the last of the actionable spec/code drifts found during the migration-prep work; the remaining A–J entries in docs/api/README.md are deliberate "converge during the Go port" decisions, not bugs.

@rado0x54 rado0x54 merged commit 6efa2ff into develop Jul 2, 2026
17 checks passed
@rado0x54 rado0x54 deleted the fix/endpoints-require-label-host branch July 2, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant