From 10d42096752f53c6b110c4169b152ac2fc58a9ff Mon Sep 17 00:00:00 2001 From: Dorian Date: Fri, 31 Jul 2026 19:01:19 -0400 Subject: [PATCH] fix(bots): guard possibly-undefined route param, bump arena image to 1.2.11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tsc --noEmit (run standalone, not filtered through a shell wrapper that silently swallowed the real exit code) caught what my own verification missed the first time: c.req.param('name') is typed possibly-undefined in this Hono router's inferred route map, and the podman build's own `pnpm --filter server build` step (which runs the real tsc, unlike a loosely-configured local check) failed on it — 1.2.10 was never actually built with the :name/ai-config routes as a result. Added an explicit guard (matches the 404 semantics of a missing param) to all three new handlers. Also bumps docker-compose.arena.yml to the 1.2.11 tag being built next. Co-Authored-By: Claude --- docker-compose.arena.yml | 2 +- server/src/routes/bots.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docker-compose.arena.yml b/docker-compose.arena.yml index 07b187e..9cbde62 100644 --- a/docker-compose.arena.yml +++ b/docker-compose.arena.yml @@ -18,7 +18,7 @@ services: botfights-arena: - image: localhost:3000/lfg2025/botfights:1.2.9 + image: localhost:3000/lfg2025/botfights:1.2.11 container_name: botfights-arena restart: unless-stopped ports: diff --git a/server/src/routes/bots.ts b/server/src/routes/bots.ts index cdaae6c..c35b30c 100644 --- a/server/src/routes/bots.ts +++ b/server/src/routes/bots.ts @@ -210,6 +210,7 @@ botsRouter.delete('/ai-config', async (c) => { // because ordering is load-bearing here. botsRouter.get('/:name/ai-config', async (c) => { const name = c.req.param('name') + if (!name) return c.json({ error: 'Bot not found.' }, 404) const rows = await db.select({ id: schema.bots.id }) .from(schema.bots) .where(eq(sql`LOWER(${schema.bots.name})`, name.toLowerCase())) @@ -225,6 +226,7 @@ botsRouter.get('/:name/ai-config', async (c) => { botsRouter.post('/:name/ai-config', rateLimit(60_000, 10), async (c) => { const name = c.req.param('name') + if (!name) return c.json({ error: 'Bot not found.' }, 404) const rows = await db.select({ id: schema.bots.id }) .from(schema.bots) .where(eq(sql`LOWER(${schema.bots.name})`, name.toLowerCase())) @@ -251,6 +253,7 @@ botsRouter.post('/:name/ai-config', rateLimit(60_000, 10), async (c) => { botsRouter.delete('/:name/ai-config', async (c) => { const name = c.req.param('name') + if (!name) return c.json({ error: 'Bot not found.' }, 404) const rows = await db.select({ id: schema.bots.id }) .from(schema.bots) .where(eq(sql`LOWER(${schema.bots.name})`, name.toLowerCase()))