{"record":{"id":"03ca9dee87c26a5f","repo":"mastra-ai/mastra","slug":"resourceid-is-required","errorCode":null,"errorMessage":"resourceId is required","messagePattern":"resourceId is required","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/memory.ts","lineNumber":811,"sourceCode":"      // After buffering, fetch the updated record\n      const memory = await getMemoryFromContext({ mastra, agentId, requestContext });\n      if (!memory) {\n        throw new HTTPException(400, { message: 'Memory is not configured for this agent' });\n      }\n\n      let memoryStore: MemoryStorage | undefined;\n      try {\n        memoryStore = await memory.storage.getStore('memory');\n      } catch {\n        throw new HTTPException(400, { message: 'Memory storage is not initialized' });\n      }\n      if (!memoryStore) {\n        throw new HTTPException(400, { message: 'Memory storage is not initialized' });\n      }\n\n      const effectiveResourceId = resourceId;\n      if (!effectiveResourceId) {\n        throw new HTTPException(400, { message: 'resourceId is required' });\n      }\n\n      const omThreadId = omConfig.scope === 'resource' ? null : (threadId ?? null);\n      const record = await memoryStore.getObservationalMemory(omThreadId, effectiveResourceId);\n\n      return { record: record ?? null };\n    } catch (error) {\n      console.error('Error awaiting buffer status', error);\n      return handleError(error, 'Error awaiting buffer status');\n    }\n  },\n});\n\nexport const LIST_THREADS_ROUTE = createRoute({\n  method: 'GET',\n  path: '/memory/threads',\n  responseType: 'json',\n  queryParamSchema: listThreadsQuerySchema,","sourceCodeStart":793,"sourceCodeEnd":829,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/memory.ts#L793-L829","documentation":"The buffer-status request omitted resourceId. Even in resource-scoped OM (where threadId is ignored), the record is keyed by resource, so the handler requires a non-empty resourceId before reading the OM record from storage.","triggerScenarios":"POST /api/memory/observational-memory/buffer-status with agentId/threadId but no resourceId in the body — e.g. polling starts before the resource is created on a 'new chat' screen, or the client sends threadId only.","commonSituations":"Chat UIs that lazily create resources after the first message and poll buffer status too early; body schema not enforcing resourceId in an older client; empty-string resourceId after a failed resource creation.","solutions":["Include resourceId in the request body alongside agentId and threadId.","Defer polling until the resource id exists (after first message/resource creation).","Validate the body client-side and skip the call when resourceId is falsy, treating buffering as not started."],"exampleFix":"// before\nbody: JSON.stringify({ agentId, threadId })\n// after\nbody: JSON.stringify({ agentId, threadId, resourceId })","handlingStrategy":"validation","validationCode":"if (!resourceId) {\n  // resource not created yet; treat buffering as not started\n  return { record: null };\n}\nawait fetch('/api/memory/observational-memory/buffer-status', {\n  method: 'POST',\n  body: JSON.stringify({ agentId, threadId, resourceId }),\n});","typeGuard":"function canPollBufferStatus(p: { agentId?: string; threadId?: string; resourceId?: string }): p is { agentId: string; threadId: string; resourceId: string } {\n  return !!(p.agentId && p.threadId && p.resourceId);\n}","tryCatchPattern":"try {\n  return await pollBufferStatus(params);\n} catch (e) {\n  if (isHttpError(e, 400) && /resourceId is required/.test(e.message)) {\n    return { record: null }; // resource not established yet\n  }\n  throw e;\n}","preventionTips":["Create the resource before starting any OM polling loop","Validate request bodies against the route schema in the client","Reject empty-string ids as if absent","Keep resourceId alongside threadId in your chat state store"],"tags":["validation","missing-parameter","observational-memory"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}