From b7d324e8cf0a35281b21b946c39e7fdf7edae65c Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Tue, 20 Oct 2026 11:27:13 +0200 Subject: [PATCH] test(cli): keep the Hub deploy fixture alive on malformed requests An empty request body crashed the HTTP fixture outside its assertions. Return HTTP 400 for invalid JSON and exercise that request before the full validation and installation assertions. --- packages/cli/tests/37-hub-deploy.test.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/cli/tests/37-hub-deploy.test.ts b/packages/cli/tests/37-hub-deploy.test.ts index 6f421d3b61..ae84519411 100644 --- a/packages/cli/tests/37-hub-deploy.test.ts +++ b/packages/cli/tests/37-hub-deploy.test.ts @@ -17,7 +17,15 @@ const server = createServer((request, response) => { body += chunk; }); request.on("end", () => { - requests.push({ url: request.url, body: JSON.parse(body) }); + let parsed: unknown; + try { + parsed = JSON.parse(body); + } catch { + response.writeHead(400); + response.end(); + return; + } + requests.push({ url: request.url, body: parsed }); const validation = request.url?.endsWith("/validate") === true; response.writeHead(validation ? 200 : 201, { "content-type": "application/json" }); response.end( @@ -59,6 +67,11 @@ try { await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve)); const address = server.address() as AddressInfo; const origin = `http://127.0.0.1:${address.port}`; + // A malformed request must not kill the fixture or satisfy a deployment assertion. + const malformed = await fetch(`${origin}/api/v1/configurations/validate`, { method: "POST" }); + assert.equal(malformed.status, 400); + assert.equal(requests.length, 0); + const validate = await runLocalPaseo( [ "hub",