From e4ab316660826eae80cd6fd5cc128109e0cb24d3 Mon Sep 17 00:00:00 2001 From: nikit Date: Mon, 6 Jul 2026 20:52:20 -0400 Subject: [PATCH] fix(work): return 400 when jobName is missing instead of defaulting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the jobName query param was missing, the code searched user.workConfig.jobs for a job with name === null, which always returned undefined, then silently proceeded with hourlyRate=0 and the default weeklyTarget=20 instead of erroring — masking the missing parameter as if the user simply had no hours logged. Verified live: before the fix, GET /api/work/summary (no jobName) returned 200 with hourlyRate:0; after the fix it returns 400 with a clear error, while a valid jobName still resolves the real job config correctly. Fixes #26 --- src/app/api/work/summary/route.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app/api/work/summary/route.ts b/src/app/api/work/summary/route.ts index 99a250b..d86467f 100644 --- a/src/app/api/work/summary/route.ts +++ b/src/app/api/work/summary/route.ts @@ -24,6 +24,9 @@ export async function GET(req: NextRequest) { const { searchParams } = new URL(req.url); const jobName = searchParams.get("jobName"); + if (!jobName) { + return NextResponse.json({ error: "jobName is required" }, { status: 400 }); + } const now = new Date(); const todayStart = startOfDay(now);