{"record":{"id":"1a6628d7582485e1","repo":"mastra-ai/mastra","slug":"no-versions-found-for-skill-id-1a6628","errorCode":null,"errorMessage":"No versions found for skill ${id}","messagePattern":"No versions found for skill (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/skills/inmemory.ts","lineNumber":152,"sourceCode":"      ...existingConfig,\n      ...(authorId !== undefined && { authorId }),\n      ...(visibility !== undefined && { visibility }),\n      ...(activeVersionId !== undefined && { activeVersionId }),\n      ...(status !== undefined && { status: status as StorageSkillType['status'] }),\n      updatedAt: new Date(),\n    };\n\n    // Auto-set status to 'published' when activeVersionId is set, only if status is not explicitly provided\n    if (activeVersionId !== undefined && status === undefined) {\n      updatedConfig.status = 'published';\n    }\n\n    // If config fields are being updated, create a new version\n    if (hasConfigUpdate) {\n      // Get the latest version to use as base\n      const latestVersion = await this.getLatestVersion(id);\n      if (!latestVersion) {\n        throw new Error(`No versions found for skill ${id}`);\n      }\n\n      // Extract config from latest version\n      const {\n        id: _versionId,\n        skillId: _skillId,\n        versionNumber: _versionNumber,\n        changedFields: _changedFields,\n        changeMessage: _changeMessage,\n        createdAt: _createdAt,\n        ...latestConfig\n      } = latestVersion;\n\n      // Merge updates into latest config\n      const newConfig = {\n        ...latestConfig,\n        ...configFields,\n      };","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/skills/inmemory.ts#L134-L170","documentation":"When update() receives config-field changes, in-memory skills storage reads the latest version to use as the base for a new version. If the skill exists but has no versions recorded in the map, there is nothing to derive from, so it throws. This mirrors the filesystem variant but for in-memory state.","triggerScenarios":"Calling update with config fields on a skill created without any version records (e.g. state populated directly into db.skills in tests); getLatestVersion returning undefined because versions were never seeded or were cleared.","commonSituations":"Tests that hand-craft skill entries without versions; clearing the versions map independently; code paths that create skill metadata bypassing the version-creation step.","solutions":["Recreate the skill through the normal create path so an initial version is written.","Seed at least one version for the skill before applying config updates.","Update only metadata fields (authorId, visibility, activeVersionId, status) which do not require a version base.","Fix the bypassing code path so skill creation always writes an initial version."],"exampleFix":"// before\nawait skillsStorage.update({ id: 'deploy', instructions: 'v2' }); // throws: no versions\n// after\nawait skillsStorage.create({ skill: { id: 'deploy', instructions: 'v2', ...rest } }); // creates version 1","handlingStrategy":"validation","validationCode":"const latest = await storage.getLatestVersion(id);\nif (!latest) throw new Error(`skill ${id} has no versions; recreate via create()`);","typeGuard":"async function hasVersionHistory(storage: InMemorySkillsStorage, id: string): Promise<boolean> {\n  return (await storage.getLatestVersion(id)) != null;\n}","tryCatchPattern":"try {\n  return await storage.update(input);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('No versions found for skill')) {\n    // metadata-only fallback or recreate\n    return null;\n  }\n  throw e;\n}","preventionTips":["Create skills only via the storage API so version 1 always exists.","Don't mutate the internal db.skills map directly in tests.","Fix code paths that create skill metadata without versions.","Fall back to metadata-only updates when version history is absent."],"tags":["storage","corrupt-state","skills","in-memory","versions"],"backgroundTag":"missing-version-history","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}