fix(api): reject POST /api/endpoints without label or host#231
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the last spec-vs-code drift found during the #225 parity work:
POST /api/endpointsaccepted a body with nolabel/hostand still returned{status:"created"}, persisting a blank endpoint — even thoughopenapi.yamlmarks 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— rejectPOST /api/endpointswith 400{ error: "label and host are required" }when either is missing or whitespace-only; the trimmed values are what get persisted.usernamestill defaults toshellwatch, so onlylabel/hostare required — matching the spec'srequired: [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-fieldscharacterizes the behavior (POST {host}→ 400). Verified no existing test creates an endpoint without label/host, so nothing regressed.Validation
pnpm test323/323,pnpm test:integration182/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.