mastra-ai/mastra · error

No versions found for workspace ${id}

Error message

No versions found for workspace ${id}

What it means

Thrown by update() when a config-field change requires creating a new workspace version, but getLatestVersion(id) returns nothing. Every workspace created through create() seeds an initial version, so this means the workspace has versions missing entirely. It protects the version-diff invariant: a new version must be based on the previous one's config.

Source

Thrown at packages/core/src/storage/domains/workspaces/inmemory.ts:139

      ...(activeVersionId !== undefined && { activeVersionId }),
      ...(status !== undefined && { status: status as StorageWorkspaceType['status'] }),
      ...(metadata !== undefined && {
        metadata: { ...existingConfig.metadata, ...metadata },
      }),
      updatedAt: new Date(),
    };

    // Auto-set status to 'published' when activeVersionId is set, only if status is not explicitly provided
    if (activeVersionId !== undefined && status === undefined) {
      updatedConfig.status = 'published';
    }

    // If config fields are being updated, create a new version
    if (hasConfigUpdate) {
      // Get the latest version to use as base
      const latestVersion = await this.getLatestVersion(id);
      if (!latestVersion) {
        throw new Error(`No versions found for workspace ${id}`);
      }

      // Extract config from latest version
      const {
        id: _versionId,
        workspaceId: _workspaceId,
        versionNumber: _versionNumber,
        changedFields: _changedFields,
        changeMessage: _changeMessage,
        createdAt: _createdAt,
        ...latestConfig
      } = latestVersion;

      // Merge updates into latest config
      const newConfig = {
        ...latestConfig,
        ...configFields,
      };

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Recreate the workspace via storage.workspaces.create() so a fresh initial version is seeded, then apply your update
  2. Seed an initial version with createVersion({ id, workspaceId: id, versionNumber: 1, config: existingConfig, ... }) before updating config fields
  3. Restore the deleted version rows from backup or migration tooling
  4. Check whether a test fixture inserted workspaces directly into storage bypassing create()

Example fix

// before
await storage.workspaces.update({ id: id, name: 'Renamed' }); // throws when no versions exist
// after
const latest = await storage.workspaces.getLatestVersion(id);
if (!latest) {
  const cfg = await storage.workspaces.getWorkspaceById(id);
  await storage.workspaces.createVersion({ id: crypto.randomUUID(), workspaceId: id, versionNumber: 1, config: cfg.config, createdAt: new Date() });
}
await storage.workspaces.update({ id: id, name: 'Renamed' });
Defensive patterns

Strategy: validation

Validate before calling

const latest = await storage.workspaces.getLatestVersion(id);
if (!latest) throw new Error(`Workspace ${id} has no versions; seed an initial version before config updates`);

Try / catch

try {
  await storage.workspaces.update({ id, ...configUpdates });
} catch (err) {
  if (err instanceof Error && err.message.startsWith('No versions found for workspace')) {
    // seed initial version from current config, then retry the update once
  } else throw err;
}

Prevention

When it happens

Trigger: Calling update({ id, ...configField }) where the workspace exists but no version rows exist for it (e.g. versions were deleted directly, seeded only via raw db.workspaces map manipulation, or created against a backend that lost version rows); combining metadata-only updates is fine — only config updates hit this path.

Common situations: Manually deleting workspace_versions rows in a database while keeping the workspace row; test fixtures that inject workspace configs without seeding a v1 version; upgrading across versions of storage schemas where version rows were not migrated.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/e7d63f01039b9075. Report an issue: GitHub.