Skip to content

refactor: extract payload ingestion and validation module from HTTP handler (#139) - #140

Merged
jonbaldie merged 1 commit into
mainfrom
fleet/worktree-jonbaldie-queue-139
Sep 25, 2026
Merged

jonbaldie merged 1 commit into
mainfrom
fleet/worktree-jonbaldie-queue-139

Conversation

@jonbaldie

Copy link
Copy Markdown
Owner

Closes #139

Summary

Extracts payload streaming, size limits, UTF-8 decoding, JSON parsing, nesting depth limits, and number precision validation from src/handler.ts into a dedicated src/payload.ts module.

Changes

  • src/payload.ts: creates deep payload ingestion module exporting readAndValidatePayload, parsePayloadBody, constants (DEFAULT_MAX_PAYLOAD_SIZE, MAX_JSON_DEPTH), and domain errors (PayloadTooLargeError, InvalidPayloadError, JsonNestingTooDeepError, UnsupportedNumberError).
  • src/handler.ts: delegates request payload parsing to src/payload.ts and maps errors to HTTP 400 and 413 responses in enqueueErrorResponse.
  • tests/payload_test.ts: tests payload parsing, depth caps, number precision, and streaming size limits directly against streams and byte arrays without HTTP scaffolding.
  • scripts/messcript.mjs: adds payload to production quality gate scope.
  • mutation/mutasaurus_ci.ts: adds tests/payload_test.ts to testFiles.

@jonbaldie
jonbaldie merged commit 176cddf into main Sep 25, 2026
4 checks passed
@jonbaldie
jonbaldie deleted the fleet/worktree-jonbaldie-queue-139 branch September 25, 2026 10:39
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.

Architecture: Extract Payload ingestion and validation module from HTTP handler

1 participant