{"record":{"id":"5460af538b2b58d0","repo":"mastra-ai/mastra","slug":"failed-to-resolve-created-skill","errorCode":null,"errorMessage":"Failed to resolve created skill","messagePattern":"Failed to resolve created skill","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"packages/server/src/server/handlers/stored-skills.ts","lineNumber":372,"sourceCode":"          visibility,\n          name,\n          description,\n          instructions,\n          license,\n          compatibility,\n          source,\n          references: indexedPaths.references ?? references,\n          scripts: indexedPaths.scripts ?? scripts,\n          assets: indexedPaths.assets ?? assets,\n          files,\n          metadata: scopeStoredResourceMetadata(metadata, await getStoredResourceScope(mastra, requestContext)),\n        },\n      });\n\n      // Return the resolved skill (thin record + version config)\n      const resolved = await skillStore.getByIdResolved(id);\n      if (!resolved) {\n        throw new HTTPException(500, { message: 'Failed to resolve created skill' });\n      }\n\n      return enrichOrStripFavorites(mastra, requestContext, 'skill', resolved);\n    } catch (error) {\n      return handleError(error, 'Error creating stored skill');\n    }\n  },\n});\n\n/**\n * PATCH /stored/skills/:storedSkillId - Update a stored skill\n */\nexport const UPDATE_STORED_SKILL_ROUTE = createRoute({\n  method: 'PATCH',\n  path: '/stored/skills/:storedSkillId',\n  responseType: 'json',\n  pathParamSchema: storedSkillIdPathParams,\n  bodySchema: updateStoredSkillBodySchema,","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/stored-skills.ts#L354-L390","documentation":"This 500 is thrown when a skill was just created but the immediate `skillStore.getByIdResolved(id)` read-back returns null, meaning the server cannot assemble the resolved skill (thin record + version config) to return. The write succeeded enough not to throw, but the follow-up read found nothing. This indicates an internal consistency/storage anomaly right after create.","triggerScenarios":"Storage adapter with read-after-write inconsistency (e.g. replication lag or caching layer); the create wrote a record that `getByIdResolved` cannot resolve because version config rows were not committed; concurrent delete of the same ID between create and read-back.","commonSituations":"Custom/experimental storage adapters; distributed Postgres with read replicas serving the immediate read; a bug in a custom `getByIdResolved` implementation; concurrent workers deleting duplicate skills.","solutions":["Retry the GET /api/stored-skills/:id request — the record may be readable a moment later","Use a storage adapter with strong read-after-write consistency (single primary, no stale replicas)","Check the adapter's `getByIdResolved` implementation for bugs resolving version config","Enable storage logging to confirm the create actually persisted the record and its version rows"],"exampleFix":"// before\nconst skill = await createSkill(...).then(r => r.json());\n// after\nconst res = await createSkill(...);\nif (res.status === 500) {\n  await new Promise(r => setTimeout(r, 250));\n  const skill = await fetch(`/api/stored-skills/${id}`).then(r => r.json());\n}","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  const created = await createStoredSkill(body);\n  return created;\n} catch (e) {\n  if (String((e as Error).message).includes('Failed to resolve created skill')) {\n    await new Promise(r => setTimeout(r, 250));\n    return fetch(`/api/stored-skills/${id}`).then(r => r.json()); // read-back retry\n  }\n  throw e;\n}","preventionTips":["Use storage with strong read-after-write consistency","Avoid custom getByIdResolved implementations unless well tested","Avoid concurrent create/delete of the same skill ID","Retry the read (not the create) on this error to avoid duplicates"],"tags":["storage","consistency","http-500","read-after-write"],"backgroundTag":"post-write-readback-failure","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}