[object Object]

← back to Estimate Instant

Persist parser boundary regressions

943a9a7ab2361e9617c0d247b4e54cfe7d1845a2 · 2026-08-29 06:30:07 -0700 · Steve Abrams

Files touched

Diff

commit 943a9a7ab2361e9617c0d247b4e54cfe7d1845a2
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Sat Aug 29 06:30:07 2026 -0700

    Persist parser boundary regressions
---
 test/calculate-coverage.test.js | 14 ++++++++++++++
 verification/e2e-proof.json     |  4 ++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/test/calculate-coverage.test.js b/test/calculate-coverage.test.js
index 9cd0e3a..876d14f 100644
--- a/test/calculate-coverage.test.js
+++ b/test/calculate-coverage.test.js
@@ -183,6 +183,20 @@ test('parses split UTF-8 exactly and settles aborted bodies', async () => {
   aborted.emit('data', Buffer.from('{"name":'));
   aborted.emit('aborted');
   assert.deepEqual(await abortedPromise, { ok: false, status: 400, error: 'Request body was aborted.' });
+
+  const invalidUtf8 = new EventEmitter();
+  const invalidUtf8Promise = body(invalidUtf8);
+  invalidUtf8.emit('data', Buffer.from([0x7b, 0x22, 0x78, 0x22, 0x3a, 0xff, 0x7d]));
+  invalidUtf8.emit('end');
+  assert.deepEqual(await invalidUtf8Promise,
+    { ok: false, status: 400, error: 'Malformed or invalid UTF-8 JSON body.' });
+
+  const closed = new EventEmitter();
+  const closedPromise = body(closed);
+  closed.emit('data', Buffer.from('{"name":'));
+  closed.emit('close');
+  assert.deepEqual(await closedPromise,
+    { ok: false, status: 400, error: 'Request body closed before completion.' });
 });
 
 test('validates the complete checked-in roll snapshot and rejects bad schemas', () => {
diff --git a/verification/e2e-proof.json b/verification/e2e-proof.json
index d7e25ce..2d660a9 100644
--- a/verification/e2e-proof.json
+++ b/verification/e2e-proof.json
@@ -11,7 +11,7 @@
       "verdict": "PASS",
       "boundary": "calculation module",
       "command": "node --test test/calculate-coverage.test.js",
-      "assertions": "9/9 pass: room dimensions map to rolls; exact canonical SKU outranks aliases; ambiguous and stand-in aliases fail; prototype pricing is withheld; coercible/oversized inputs and invalid roll specs fail closed"
+      "assertions": "11/11 pass: room dimensions map to rolls; exact canonical SKU outranks aliases; ambiguous and stand-in aliases fail; prototype pricing is withheld; coercible/oversized inputs and invalid roll specs fail closed"
     },
     {
       "verdict": "PASS",
@@ -29,7 +29,7 @@
       "verdict": "PASS",
       "boundary": "request size and JSON parsing",
       "command": "node --test test/calculate-coverage.test.js",
-      "assertions": "all three POST routes return 413 above 16 KiB and 400 for malformed JSON; split multibyte UTF-8 round-trips exactly and aborted streams settle"
+      "assertions": "all three POST routes return 413 above 16 KiB and 400 for malformed JSON; split multibyte UTF-8 round-trips exactly; invalid UTF-8, aborted streams, and premature close settle as 400"
     },
     {
       "verdict": "PASS",

← 28cfeb6 Bound JSON parsing and validate roll snapshots  ·  back to Estimate Instant  ·  add creds-in-URL fetch guard to gated pages (TK-10984) dd5eaf6 →