{"record":{"id":"58594df66d96f8fe","repo":"thedotmack/claude-mem","slug":"not-found","errorCode":"not_found","errorMessage":"not_found","messagePattern":"not_found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"src/server/routes/v1/ServerV1PostgresRoutes.ts","lineNumber":1093,"sourceCode":"      await server.connect(transport);\n      await transport.handleRequest(req, res, req.body);\n    });\n    // MCP streamable-HTTP only uses POST (JSON-RPC) and GET (SSE). Scope the\n    // route to those instead of app.all, so DELETE/PUT/PATCH/OPTIONS don't run\n    // auth + transport only to be rejected.\n    app.post('/v1/mcp', readAuth, mcpHandler);\n    app.get('/v1/mcp', readAuth, mcpHandler);\n\n    // DELETE /v1/memories/:id — forget a single observation (sources cascade).\n    app.delete('/v1/memories/:id', writeAuth, this.asyncHandler(async (req, res) => {\n      const teamId = this.requireTeamId(req, res);\n      if (!teamId) return;\n      const id = String(req.params.id);\n      const projectScope = req.authContext?.projectId ?? null;\n      try {\n        const deleted = await this.deleteObservationForScope(id, teamId, projectScope);\n        if (!deleted) {\n          res.status(404).json({ error: 'not_found' });\n          return;\n        }\n        await this.auditWrite(req, 'observation.deleted', id, projectScope, { via: 'api' });\n        res.status(200).json({ deleted: true, id });\n      } catch (error) {\n        const err = error instanceof Error ? error : new Error(String(error));\n        logger.warn('SYSTEM', 'observation.delete failed', { requestId: req.requestId ?? null }, err);\n        this.handleDbError(err, res, 'observation.delete');\n      }\n    }));\n\n    // DELETE /v1/projects/:projectId/memory — forget EVERYTHING captured for a\n    // project (observations, raw events, sessions, jobs). Keeps the project shell.\n    app.delete('/v1/projects/:projectId/memory', writeAuth, this.asyncHandler(async (req, res) => {\n      const teamId = this.requireTeamId(req, res);\n      if (!teamId) return;\n      const projectId = String(req.params.projectId);\n      if (!this.ensureProjectAllowed(req, res, projectId)) return;","sourceCodeStart":1075,"sourceCodeEnd":1111,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/server/routes/v1/ServerV1PostgresRoutes.ts#L1075-L1111","documentation":"DELETE /v1/observations/:id returns 404 with a bare { error: 'not_found' } body when deleteObservationForScope deletes nothing — either no observation with that id exists for the caller's team, or it exists but belongs to a project the caller's project-scoped key cannot touch. Note this route uses lowercase 'not_found' and no message field, unlike other 404s in the same file.","triggerScenarios":"Deleting an observation id that was already deleted, an id from another team, or using a project-scoped key on an observation belonging to a different project.","commonSituations":"Double-invocation of delete in a queue consumer; syncing deletion by IDs harvested from another environment; scope-mismatched keys after project re-org.","solutions":["Confirm the observation id exists and belongs to the team/project bound to your key before deleting","Make deletion idempotent: treat 404 as 'already deleted' and succeed silently in cleanup workflows","List observations first to obtain valid, in-scope ids"],"exampleFix":"// before\nawait api.delete(`/v1/observations/${id}`); // crashes workflow on 404\n// after\nconst res = await api.delete(`/v1/observations/${id}`);\nif (res.status === 404) return; // already deleted — idempotent cleanup\nif (!res.ok) throw new Error(`delete failed: ${res.status}`);","handlingStrategy":"try-catch","validationCode":"const list = await listObservations({ projectId });\nif (!list.some(o => o.id === id)) {\n  return; // nothing to delete for this team/project\n}","typeGuard":null,"tryCatchPattern":"const res = await api.delete(`/v1/observations/${id}`);\nif (res.status === 404) return; // already deleted or out of scope — idempotent\nif (!res.ok) throw new Error(`observation delete failed: ${res.status}`);","preventionTips":["Make delete workflows idempotent (queue consumers may double-deliver)","Only delete ids listed with the same key/team","Watch for the lowercase 'not_found' body on this route when parsing errors"],"tags":["http","api","not-found","delete","scope"],"backgroundTag":"record-not-found","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}