From 8f9096c626112f5d8ff72c1b34c8a891f0cd75e4 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Feb 2026 01:25:31 +0000 Subject: [PATCH] Parse negative port args as invalid values Co-authored-by: Theo Browne --- apps/t3/src/cli.test.ts | 12 ++++++++++++ apps/t3/src/cli.ts | 7 +++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/t3/src/cli.test.ts b/apps/t3/src/cli.test.ts index 3a7c14c9c2..3d3b38580f 100644 --- a/apps/t3/src/cli.test.ts +++ b/apps/t3/src/cli.test.ts @@ -237,12 +237,24 @@ describe("parseCliOptions", () => { ); }); + it("rejects negative backend port values provided as separate args", () => { + expect(() => parseCliOptions(["--backend-port", "-1"], {}, "/workspace")).toThrow( + "Invalid value for --backend-port", + ); + }); + it("throws when web port value is missing", () => { expect(() => parseCliOptions(["--web-port"], {}, "/workspace")).toThrow( "Missing value for --web-port", ); }); + it("rejects negative web port values provided as separate args", () => { + expect(() => parseCliOptions(["--web-port", "-1"], {}, "/workspace")).toThrow( + "Invalid value for --web-port", + ); + }); + it("throws for invalid environment port values", () => { expect(() => parseCliOptions([], { T3_WEB_PORT: "nope" }, "/workspace")).toThrow( "Invalid value for T3_WEB_PORT", diff --git a/apps/t3/src/cli.ts b/apps/t3/src/cli.ts index a11eb1d22e..dc2198fa11 100644 --- a/apps/t3/src/cli.ts +++ b/apps/t3/src/cli.ts @@ -198,7 +198,7 @@ export function parseCliOptions( if (arg === "--backend-port") { backendPort = parseExplicitPort( - readArgValue(argv, index, "--backend-port"), + readArgValue(argv, index, "--backend-port", { allowDashPrefixed: true }), "--backend-port", ); backendPortLocked = true; @@ -213,7 +213,10 @@ export function parseCliOptions( } if (arg === "--web-port") { - webPort = parseExplicitPort(readArgValue(argv, index, "--web-port"), "--web-port"); + webPort = parseExplicitPort( + readArgValue(argv, index, "--web-port", { allowDashPrefixed: true }), + "--web-port", + ); webPortLocked = true; index += 1; continue;