{"record":{"id":"5f2729bd5c0255ec","repo":"mastra-ai/mastra","slug":"failed-to-resolve-updated-skill","errorCode":null,"errorMessage":"Failed to resolve updated skill","messagePattern":"Failed to resolve updated skill","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"packages/server/src/server/handlers/stored-skills.ts","lineNumber":483,"sourceCode":"      if (compatibility !== undefined) update.compatibility = compatibility;\n      if (source !== undefined) update.source = source;\n      const resolvedReferences = indexedPaths.references ?? references;\n      const resolvedScripts = indexedPaths.scripts ?? scripts;\n      const resolvedAssets = indexedPaths.assets ?? assets;\n      if (resolvedReferences !== undefined) update.references = resolvedReferences;\n      if (resolvedScripts !== undefined) update.scripts = resolvedScripts;\n      if (resolvedAssets !== undefined) update.assets = resolvedAssets;\n      if (files !== undefined) update.files = files;\n      if (metadata !== undefined) {\n        update.metadata = scopeStoredResourceMetadata({ ...(existing.metadata ?? {}), ...metadata }, scope);\n      }\n\n      await skillStore.update(update as Parameters<typeof skillStore.update>[0]);\n\n      // Return the resolved skill with the updated config\n      const resolved = await skillStore.getByIdResolved(storedSkillId);\n      if (!resolved) {\n        throw new HTTPException(500, { message: 'Failed to resolve updated skill' });\n      }\n\n      return enrichOrStripFavorites(mastra, requestContext, 'skill', resolved);\n    } catch (error) {\n      return handleError(error, 'Error updating stored skill');\n    }\n  },\n});\n\n/**\n * DELETE /stored/skills/:storedSkillId - Delete a stored skill\n */\nexport const DELETE_STORED_SKILL_ROUTE = createRoute({\n  method: 'DELETE',\n  path: '/stored/skills/:storedSkillId',\n  responseType: 'json',\n  pathParamSchema: storedSkillIdPathParams,\n  responseSchema: deleteStoredSkillResponseSchema,","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/stored-skills.ts#L465-L501","documentation":"This 500 mirrors error 3085 but on the update path: after `skillStore.update(...)` succeeded, `getByIdResolved(storedSkillId)` still returned null so the handler cannot return the resolved updated skill. The update write and the subsequent resolve read disagree, indicating a storage consistency or resolution bug rather than caller error.","triggerScenarios":"An update that effectively removed/deactivated the record while reporting success (adapter bug); read replica serving stale data immediately after the update; concurrent request deleting the skill between `update` and `getByIdResolved`; custom adapter whose `update` doesn't persist all fields `getByIdResolved` needs.","commonSituations":"Databases with eventual consistency (cached reads); experimental storage adapters; race conditions in scripts performing update+delete on the same skill.","solutions":["Re-fetch the skill shortly after; the next read will likely see the committed update","Use a strongly consistent storage adapter (single primary reads) for the skills domain","Check for concurrent processes deleting the skill and serialize update/delete workflows","Audit a custom adapter's `update` and `getByIdResolved` implementations for mismatched expectations"],"exampleFix":"// before\nawait updateSkill(id, patch);\nconst skill = await getSkill(id); // may 500 right after write\n// after\nawait updateSkill(id, patch);\nlet skill;\nfor (let i = 0; i < 3 && !skill; i++) {\n  await new Promise(r => setTimeout(r, 200));\n  skill = await getSkill(id).catch(() => null);\n}","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await updateStoredSkill(id, patch);\n} catch (e) {\n  if (String((e as Error).message).includes('Failed to resolve updated skill')) {\n    await new Promise(r => setTimeout(r, 300));\n    return fetch(`/api/stored-skills/${id}`).then(r => r.json());\n  }\n  throw e;\n}","preventionTips":["Prefer strongly consistent storage (no stale replica reads) for skills","Serialize update/delete operations on the same skill ID","Test custom adapters for update-then-resolve consistency","Retry the read-back rather than re-sending the update"],"tags":["storage","consistency","http-500","update"],"backgroundTag":"post-write-readback-failure","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}