{"record":{"id":"7cfb5d28ac54d4b2","repo":"thedotmack/claude-mem","slug":"validationerror-7cfb5d","errorCode":"ValidationError","errorMessage":"ValidationError","messagePattern":"ValidationError","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"src/server/routes/v1/ServerV1PostgresRoutes.ts","lineNumber":247,"sourceCode":"\n    // GET /v1/connect — the paste-ready MCP connect command (placeholder key, so\n    // a GET never mints). Use POST /v1/keys to get a real read-only key.\n    app.get('/v1/connect', readAuth, this.asyncHandler(async (req, res) => {\n      const teamId = this.requireTeamId(req, res);\n      if (!teamId) return;\n      const mcpUrl = mcpConnectUrl(req);\n      res.status(200).json({\n        mcpUrl,\n        connectCommand: mcpConnectCommand(mcpUrl, '<YOUR_API_KEY>'),\n        hint: 'POST /v1/keys (write scope) to mint a read-only key for this link.',\n      });\n    }));\n\n    // POST /v1/events — single event with optional async generation\n    app.post('/v1/events', writeAuth, this.asyncHandler(async (req, res) => {\n      const parsedQuery = EVENT_QUERY_SCHEMA.safeParse(req.query);\n      if (!parsedQuery.success) {\n        res.status(400).json({ error: 'ValidationError', issues: parsedQuery.error.issues });\n        return;\n      }\n      const generate = parsedQuery.data.generate !== 'false';\n      const wait = parsedQuery.data.wait === 'true';\n\n      const result = CreateAgentEventSchema.safeParse(req.body);\n      if (!result.success) {\n        res.status(400).json({ error: 'ValidationError', issues: result.error.issues });\n        return;\n      }\n      const body = result.data;\n      const teamId = this.requireTeamId(req, res);\n      if (!teamId) return;\n      if (!this.ensureProjectAllowed(req, res, body.projectId)) return;\n\n      const insertInput = this.toAgentEventInput(body, teamId);\n      await this.applyContentSessionLinks([insertInput], [req.body], teamId);\n      let event: PostgresAgentEvent;","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/server/routes/v1/ServerV1PostgresRoutes.ts#L229-L265","documentation":"400 ValidationError on POST /v1/events for the query string: EVENT_QUERY_SCHEMA (generate/wait flags) failed zod safeParse of req.query. Only generate and wait are accepted — any other query param, or values other than the literal 'true'/'false' strings these flags parse from, produce issues in the response.","triggerScenarios":"Calling POST /v1/events?generate=1 or ?wait=yes (non-literal values); appending unrelated query params the schema rejects; URL-encoding mistakes that turn the value into something unparseable.","commonSituations":"Client sends generate=true as a boolean flag helper that serializes to '1'; copy-pasted query params from another API; typos like genrate=true.","solutions":["Read res.body.issues — zod lists the exact path and expected shape for each bad param.","Use only the literal query strings: generate='true'|'false', wait='true'|'false'.","Drop unrelated query parameters from the URL.","Omit the query string entirely if defaults (generate on, wait off) are acceptable."],"exampleFix":"# before\ncurl -X POST 'https://host/v1/events?generate=1&wait=yes' -d '{}'\n// 400 ValidationError\n\n# after\ncurl -X POST 'https://host/v1/events?generate=false' -d '{}'","handlingStrategy":"validation","validationCode":"const EVENT_QUERY_KEYS = new Set(['generate', 'wait']);\nfunction buildEventQuery(params: Record<string, string> = {}): string {\n  const bad = Object.keys(params).filter(k => !EVENT_QUERY_KEYS.has(k));\n  if (bad.length) throw new Error(`unsupported query params: ${bad.join(', ')}`);\n  for (const v of Object.values(params)) {\n    if (v !== 'true' && v !== 'false') throw new Error(`query flags must be 'true'|'false', got ${v}`);\n  }\n  return new URLSearchParams(params).toString();\n}","typeGuard":"interface ValidationBody { error: string; issues: unknown[] }\nfunction isQueryValidationError(res: Response, body: unknown): body is ValidationBody {\n  return res.status === 400 && typeof body === 'object' && body !== null &&\n    (body as ValidationBody).error === 'ValidationError';\n}","tryCatchPattern":null,"preventionTips":["Build query strings from a typed helper that whitelists keys and literal values.","Never let generic HTTP clients append default query parameters."],"tags":["validation","zod","http-400","query-params"],"backgroundTag":"schema-validation-failed","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}