{"record":{"id":"e29d643f62b4e1c6","repo":"mastra-ai/mastra","slug":"read-only-e29d64","errorCode":"READ_ONLY","errorMessage":"Workspace is in read-only mode. Cannot perform: delete","messagePattern":"Workspace is in read-only mode\\. Cannot perform: delete","errorType":"error_code","errorClass":"WorkspaceReadOnlyError","httpStatus":null,"severity":"error","filePath":"packages/core/src/workspace/tools/delete-file.ts","lineNumber":33,"sourceCode":"      .boolean()\n      .optional()\n      .default(false)\n      .describe('If true, delete directories and their contents recursively. Required for non-empty directories.'),\n  }),\n  execute: async ({ path, recursive }, context) => {\n    const { workspace, filesystem } = requireFilesystem(context);\n    await emitWorkspaceMetadata(context, WORKSPACE_TOOLS.FILESYSTEM.DELETE);\n\n    const span = startWorkspaceSpan(context, workspace, {\n      category: 'filesystem',\n      operation: 'delete',\n      input: { path, recursive },\n      attributes: { filesystemProvider: filesystem.provider },\n    });\n\n    try {\n      if (filesystem.readOnly) {\n        throw new WorkspaceReadOnlyError('delete');\n      }\n\n      const stat = await filesystem.stat(path);\n      if (stat.type === 'directory') {\n        await filesystem.rmdir(path, { recursive, force: recursive });\n      } else {\n        await filesystem.deleteFile(path);\n      }\n\n      span.end({ success: true });\n      return `Deleted ${path}`;\n    } catch (err) {\n      span.error(err);\n      throw err;\n    }\n  },\n});\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workspace/tools/delete-file.ts#L15-L51","documentation":"Thrown by the delete-file workspace tool when the filesystem is read-only. Deleting files or directories mutates the workspace, so the operation is rejected before any stat/rmdir/unlink call. Code is READ_ONLY via WorkspaceReadOnlyError naming the 'delete' operation.","triggerScenarios":"Invoking the delete tool with path (and optional recursive) on a workspace whose filesystem.readOnly is true.","commonSituations":"Agents pointed at immutable deployments or mounted read-only volumes; cleanup routines running in preview/production-inspection environments.","solutions":["Switch the filesystem provider to writable mode for the workspace","Perform deletions in an environment with write permissions (dev workspace or writable mount)","Make the target path writable at the OS/provider level if the read-only flag reflects mount permissions","Handle READ_ONLY in tool results and skip deletion steps gracefully"],"exampleFix":"// before\nfilesystem: createFilesystem({ root, readOnly: true })\n// after\nfilesystem: createFilesystem({ root, readOnly: false })","handlingStrategy":"validation","validationCode":"if (workspace.filesystem.readOnly) {\n  throw new Error('delete unavailable: workspace is read-only');\n}","typeGuard":"function canDelete(fs: WorkspaceFilesystem | undefined): fs is WorkspaceFilesystem & { readOnly: false } {\n  return !!fs && fs.readOnly === false;\n}","tryCatchPattern":"try {\n  await deleteTool.execute({ context: { path, recursive }, ... });\n} catch (e: any) {\n  if (e?.code === 'READ_ONLY') return { skipped: true, reason: 'read-only workspace' };\n  throw e;\n}","preventionTips":["Confirm filesystem writability before scheduling cleanup/cleanup agents","Expose delete tools only on writable workspaces","Remount or reconfigure read-only volumes proactively","Log READ_ONLY outcomes so misconfiguration is visible"],"tags":["read-only","workspace","delete","filesystem"],"backgroundTag":"workspace-read-only","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}