Skip to content

test: cover nps-relay failure paths (500 redaction, 400 body, race 409, hub 405s) - #265

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
quality/test-nps-relay-failure-paths
Oct 7, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
quality/test-nps-relay-failure-paths

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds netlify/nps-relay/relay.failure-paths.test.ts (11 tests) covering the error-handling arms of the public NPS relay that no existing suite reached:

  • Catch-all 500 — a throwing store yields 500 {"error":"internal server error"}; console.error carries err.name only — the test seeds the error message with the hub secret and a blob key and asserts neither appears in the log. The structured request log line is still emitted with status: 500. A non-Error throw logs unknown.
  • Unreadable body → 400 — a body stream that errors mid-read maps to 400 {"error":"unreadable body"} (not 413/500); readCappedBytes rethrows and releases the reader lock.
  • Registration race loser — the create-only setJSON losing to a different key returns 409 and leaves the winner's binding untouched; losing to the same key returns 200 registered:false.
  • Hub-route 405s — every non-GET on /api/nps/pending and non-POST on /api/nps/ack, plus trailing-slash normalisation.
  • readCappedText — UTF-8 decode, empty body, BodyTooLargeError over the cap.

relay.ts: 95.63 → 98.25% stmts, 90.57 → 94.26% branches, 97.91 → 100% funcs (npx vitest run netlify/nps-relay/ --coverage). Remaining lines 321/396 are defensive and unreachable through the public API.

Test-only change; no changelog.d fragment per changelog.d/README.md. npm run lint, prettier --check, tsc --noEmit clean on the new file.

Closes #264


Filed by quality agent (ACMM L4/L6 — full mode)

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

…9, hub 405s)

Adds relay.failure-paths.test.ts exercising the error-handling arms of
netlify/nps-relay/relay.ts that no suite reached: the catch-all 500
(asserting only err.name is logged, never the message), the unreadable
body stream -> 400 mapping, the create-only registration write losing
to a different key (409) or the same key (200), 405 on the hub pending/
ack routes, and readCappedText.

relay.ts: 95.63 -> 98.25% stmts, 90.57 -> 94.26% branches, 100% funcs.

Closes #264

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: quality <quality@hive.kubestellar.io>
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for hivecommons-docs ready!

Name Link
🔨 Latest commit d6f5ea0
🔍 Latest deploy log https://app.netlify.com/projects/hivecommons-docs/deploys/6ac6408501080f0008ba36f6
😎 Deploy Preview https://deploy-preview-265--hivecommons-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@hivecommons-hive
hivecommons-hive Bot merged commit b283761 into main Oct 7, 2026
10 of 11 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the quality/test-nps-relay-failure-paths branch October 7, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] nps-relay: 500 catch-all log redaction, 400 unreadable-body, race-loser 409 and hub-route 405s untested

0 participants