{"record":{"id":"89041b40541a1de6","repo":"mastra-ai/mastra","slug":"nested-mount-paths-are-not-supported-b-is-ne","errorCode":null,"errorMessage":"Nested mount paths are not supported: \"${b}\" is nested under \"${a}\"","messagePattern":"Nested mount paths are not supported: \"(.+?)\" is nested under \"(.+?)\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/workspace/filesystem/composite-filesystem.ts","lineNumber":112,"sourceCode":"\n    for (const [path, fs] of Object.entries(config.mounts)) {\n      const normalized = this.normalizePath(path);\n      this._mounts.set(normalized, fs);\n    }\n\n    if (this._mounts.size === 0) {\n      throw new Error('CompositeFilesystem requires at least one mount');\n    }\n\n    // Composite is read-only when every mount is read-only\n    this.readOnly = [...this._mounts.values()].every(fs => fs.readOnly) || undefined;\n\n    // Validate no nested mount paths (e.g., /data and /data/sub)\n    const mountPaths = [...this._mounts.keys()];\n    for (const a of mountPaths) {\n      for (const b of mountPaths) {\n        if (a !== b && b.startsWith(a + '/')) {\n          throw new Error(`Nested mount paths are not supported: \"${b}\" is nested under \"${a}\"`);\n        }\n      }\n    }\n  }\n\n  /**\n   * Get all mount paths.\n   */\n  get mountPaths(): string[] {\n    return Array.from(this._mounts.keys());\n  }\n\n  /**\n   * Get the mounts map.\n   * Returns a typed map where `get()` preserves the concrete filesystem type per mount path.\n   */\n  get mounts(): ReadonlyMountMap<TMounts> {\n    return this._mounts as unknown as ReadonlyMountMap<TMounts>;","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workspace/filesystem/composite-filesystem.ts#L94-L130","documentation":"CompositeFilesystem resolves a path to exactly one mount by longest-prefix match; if one mount path is nested under another (e.g., '/data' and '/data/sub'), resolution would be ambiguous. The constructor therefore rejects any mount path that starts with another mount path + '/'. This keeps path dispatch deterministic.","triggerScenarios":"new CompositeFilesystem({ mounts: { '/data': fsA, '/data/sub': fsB } }) or any mount set where one normalized path is a prefix of another.","commonSituations":"Merging mount maps from multiple config sources that share base directories; auto-generating mounts per feature folder under a common root; mounting '/' (root) together with any other path — every other mount is nested under '/'.","solutions":["Flatten the mounts so each top-level prefix is unique; merge the nested backend's files into the parent mount.","Move the nested mount to a sibling path (e.g., '/data' and '/data-sub').","If you need '/' mounted, make it the only mount, or use non-overlapping top-level prefixes.","Validate mount paths for prefix collisions in config loading before constructing the composite."],"exampleFix":"// before\nnew CompositeFilesystem({ mounts: { '/data': fsA, '/data/sub': fsB } });\n// after\nnew CompositeFilesystem({ mounts: { '/data': fsA, '/uploads/sub': fsB } }); // non-overlapping prefixes","handlingStrategy":"validation","validationCode":"const paths = Object.keys(mounts).map(p => p.replace(/\\/+$/, ''));\nfor (const a of paths) for (const b of paths) {\n  if (a !== b && b.startsWith(a + '/')) throw new Error(`Mount ${b} is nested under ${a}`);\n}","typeGuard":null,"tryCatchPattern":"try { new CompositeFilesystem({ mounts }); } catch (e) { if ((e as Error).message.includes('Nested mount paths')) { console.error('Fix mount prefixes; they must not overlap:', e.message); } throw e; }","preventionTips":["Design mount prefixes as disjoint top-level directories.","Never mount '/' alongside any other path.","Run a prefix-collision check in config tests/CI."],"tags":["workspace","filesystem","configuration","path-collision"],"backgroundTag":"mount-path-conflict","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}