{"record":{"id":"a7cc91d4f5949656","repo":"paperclipai/paperclip","slug":"failed-to-create-board-api-key","errorCode":null,"errorMessage":"Failed to create board API key","messagePattern":"Failed to create board API key","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/client/token.ts","lineNumber":162,"sourceCode":"    board\n      .command(\"create\")\n      .description(\"Create a named board API key\")\n      .option(\"-C, --company-id <id>\", \"Company ID used for audit context\")\n      .option(\"--name <name>\", \"API key label\", \"cli-board\")\n      .option(\"--expires-at <iso8601>\", \"Expiration timestamp\")\n      .option(\"--ttl-days <days>\", \"Expiration in days from now\")\n      .option(\"--never-expires\", \"Create a non-expiring key\")\n      .action(async (opts: BoardTokenOptions) => {\n        try {\n          const ctx = resolveCommandContext(opts);\n          const expiresAt = resolveBoardKeyExpiresAt(opts);\n          const payload = createBoardApiKeySchema.parse({\n            name: opts.name,\n            requestedCompanyId: opts.companyId ?? ctx.companyId ?? null,\n            expiresAt,\n          });\n          const key = await ctx.api.post<CreatedBoardKey>(\"/api/board-api-keys\", payload);\n          if (!key) throw new Error(\"Failed to create board API key\");\n          printOutput({ key }, { json: ctx.json });\n        } catch (err) {\n          handleCommandError(err);\n        }\n      }),\n    { includeCompany: false },\n  );\n\n  addCommonClientOptions(\n    board\n      .command(\"list\")\n      .description(\"List board API keys for the current board user\")\n      .action(async (opts: BaseClientOptions) => {\n        try {\n          const ctx = resolveCommandContext(opts);\n          const keys = (await ctx.api.get<BoardKeyRow[]>(\"/api/board-api-keys\")) ?? [];\n          if (ctx.json) {\n            printOutput(keys, { json: true });","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/client/token.ts#L144-L180","documentation":"Thrown by the `board create` action in token.ts when ctx.api.post to /api/board-api-keys returns a falsy value. Mirrors error 122 but for board-scope keys: the server must return a CreatedBoardKey object; an empty or unparseable body trips the guard.","triggerScenarios":"Calling `paperclipai ... token board create ...` and the server returns an empty 2xx body, or the API client resolves null because the JSON did not match the expected shape.","commonSituations":"API/CLI version skew, a proxy stripping the response body, schema validator on the client rejecting the body and resolving null, or a misconfigured base URL.","solutions":["Confirm board-api-keys POST returns a non-empty JSON body via curl.","Align CLI and server versions.","Check the API base URL and auth header are correct.","Enable CLI debug output to see the raw response."],"exampleFix":"// before: board-api-keys POST returns '' or {}\n// after: server returns the created key\nres.status(201).json({ id, key, name, expiresAt });","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isCreatedBoardKey(value: unknown): value is CreatedBoardKey {\n  return !!value && typeof value === \"object\" && \"key\" in value && typeof (value as any).key === \"string\";\n}","tryCatchPattern":"try {\n  const key = await ctx.api.post<CreatedBoardKey>(\"/api/board-api-keys\", payload);\n  if (!isCreatedBoardKey(key)) throw new Error(\"Server returned no board key body\");\n} catch (err) {\n  handleCommandError(err);\n}","preventionTips":["Align CLI and server versions.","Confirm /api/board-api-keys returns a JSON body via curl.","Check the API base URL and auth header."],"tags":["cli","board-keys","api-contract","null-response"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}