{"record":{"id":"e631ecc346dea51b","repo":"nexu-io/open-design","slug":"memory-not-found","errorCode":null,"errorMessage":"memory not found","messagePattern":"memory not found","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/memory.ts","lineNumber":490,"sourceCode":"  const { summary, body } = summarize(id, raw, stat.mtimeMs);\n  return { ...summary, body };\n}\n\nfunction renderEntryFile(name, description, type, body, source) {\n  const safeName = String(name || 'Untitled').replace(/\\r?\\n/g, ' ').trim();\n  const safeDesc = String(description || '').replace(/\\r?\\n/g, ' ').trim();\n  const safeType = isValidType(type) ? type : 'user';\n  const safeSource = VALID_SOURCES.has(source) ? source : 'manual';\n  const trimmedBody = String(body || '').replace(/^\\s+/, '');\n  return `---\\nname: ${safeName}\\ndescription: ${safeDesc}\\ntype: ${safeType}\\nsource: ${safeSource}\\n---\\n\\n${trimmedBody}\\n`;\n}\n\nexport async function updateMemoryTreeNode(dataDir, id, patch) {\n  if (typeof id !== 'string' || id.startsWith('folder:')) {\n    throw new Error('memory tree folders are derived and cannot be edited');\n  }\n  const current = await readMemoryEntry(dataDir, id);\n  if (!current) throw new Error('memory not found');\n  const nextType = isValidType(patch?.type) ? patch.type : current.type;\n  return upsertMemoryEntry(dataDir, {\n    id,\n    name:\n      typeof patch?.name === 'string' && patch.name.trim()\n        ? patch.name\n        : current.name,\n    description:\n      typeof patch?.description === 'string'\n        ? patch.description\n        : current.description,\n    type: nextType,\n    body: typeof patch?.body === 'string' ? patch.body : current.body,\n  });\n}\n\nexport async function upsertMemoryEntry(dataDir, input, options) {\n  const { name, description, type, body } = input || {};","sourceCodeStart":472,"sourceCodeEnd":508,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/memory.ts#L472-L508","documentation":"readMemoryEntry returned null when updateMemoryTreeNode tried to load the current entry before patching it. The entry file (.md) does not exist at the expected path under the memory directory, so there is nothing to update.","triggerScenarios":"Calling updateMemoryTreeNode with an id that was never created; the entry was deleted between the UI listing it and the update attempt; a concurrent process removed the .md file; filesystem issue prevented reading.","commonSituations":"Stale UI showing an entry that was deleted elsewhere; race condition between a delete and an update on the same entry; manual filesystem cleanup removed memory .md files; the id was fabricated by the caller and never corresponded to a real entry.","solutions":["Verify the entry id exists by listing current memory entries before attempting to update","Refresh the memory list to get the current set of valid entry ids","If the entry should exist, create it first via upsertMemoryEntry instead of updating","Check for concurrent memory modification operations"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check entry existence before updating\nimport { readMemoryEntry } from './memory';\n\nasync function assertMemoryEntryExists(dataDir, id) {\n  const entry = await readMemoryEntry(dataDir, id);\n  if (!entry) {\n    throw new Error(`Memory entry not found: ${id}. It may have been deleted. Refresh the list and try again.`);\n  }\n  return entry;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await updateMemoryTreeNode(dataDir, id, patch);\n} catch (err) {\n  if (err.message === 'memory not found') {\n    // Entry was deleted — offer to create instead\n    return upsertMemoryEntry(dataDir, { id, ...patch });\n  }\n  throw err;\n}","preventionTips":["Refresh the memory entry list before allowing edits to avoid stale ids","Handle concurrent deletion gracefully by falling back to create-if-missing semantics","Use optimistic concurrency checks if multiple clients can modify memory entries simultaneously"],"tags":["memory","not-found","state-management"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}