From 8d2938eddbfea75ad551d91fba8ee409e92e0558 Mon Sep 17 00:00:00 2001 From: brantsrasmus Date: Thu, 20 Aug 2026 16:25:24 +0200 Subject: [PATCH] fix: creating a board without a description returns 500 `description` is optional in the request schema, but the column is NOT NULL with no default, so an omitted description reached Prisma as undefined and the create threw a validation error instead of saving: Invalid `prisma.board.create()` invocation Argument `description` is missing. Default it to an empty string, matching what the UI sends today, and cover it with an API test. --- src/app/api/boards/route.ts | 3 +++ tests/e2e/api-board.spec.ts | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/e2e/api-board.spec.ts diff --git a/src/app/api/boards/route.ts b/src/app/api/boards/route.ts index 252b6d697..86e4e246a 100644 --- a/src/app/api/boards/route.ts +++ b/src/app/api/boards/route.ts @@ -75,6 +75,9 @@ export async function POST(request: Request) { ...body, type: normalizeBoardType(body.type), id: uuid(), + // The column is NOT NULL with no default, so an omitted description — + // which the request schema allows — reaches Prisma as undefined and throws. + description: body.description ?? '', parameters: body.parameters ?? {}, userId: !teamId ? auth.user.id : undefined, }; diff --git a/tests/e2e/api-board.spec.ts b/tests/e2e/api-board.spec.ts new file mode 100644 index 000000000..9bb0bb935 --- /dev/null +++ b/tests/e2e/api-board.spec.ts @@ -0,0 +1,35 @@ +import { expect, test } from '@playwright/test'; +import { type Auth, authHeaders, loginViaApi } from './helpers'; + +test.describe('Board API tests', () => { + test.describe.configure({ mode: 'serial' }); + + let auth: Auth; + let boardId = ''; + + test.beforeAll(async ({ request }) => { + auth = await loginViaApi(request); + }); + + test.afterAll(async ({ request }) => { + if (boardId) { + await request.delete(`/api/boards/${boardId}`, { headers: authHeaders(auth) }); + } + }); + + test('creates a board without a description', async ({ request }) => { + const response = await request.post('/api/boards', { + headers: authHeaders(auth), + data: { name: 'Playwright board', type: 'mixed' }, + }); + + expect(response.status()).toBe(200); + + const body = await response.json(); + + boardId = body.id; + + expect(body).toHaveProperty('name', 'Playwright board'); + expect(body).toHaveProperty('description', ''); + }); +});