{"record":{"id":"86c779ee400e8fc4","repo":"stride3d/stride","slug":"trying-to-convert-back-a-path-that-is-not-in-this-file","errorCode":null,"errorMessage":"Trying to convert back a path that is not in this file system provider.","messagePattern":"Trying to convert back a path that is not in this file system provider\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.IO/FileSystemProvider.cs","lineNumber":62,"sourceCode":"        // Ensure localBasePath ends with a \\\n        if (localBasePath?.EndsWith(DirectorySeparatorChar) == false)\n            localBasePath += DirectorySeparatorChar;\n    }\n\n    protected virtual string ConvertUrlToFullPath(string url)\n    {\n        if (localBasePath == null)\n            return url;\n        return localBasePath + url.Replace(VirtualFileSystem.DirectorySeparatorChar, DirectorySeparatorChar);\n    }\n\n    protected virtual string ConvertFullPathToUrl(string path)\n    {\n        if (localBasePath == null)\n            return path;\n\n        if (!path.StartsWith(localBasePath, StringComparison.OrdinalIgnoreCase))\n            throw new InvalidOperationException(\"Trying to convert back a path that is not in this file system provider.\");\n\n        return path[localBasePath.Length..].Replace(DirectorySeparatorChar, VirtualFileSystem.DirectorySeparatorChar);\n    }\n\n    public override bool DirectoryExists(string url)\n    {\n        var path = ConvertUrlToFullPath(url);\n        return Directory.Exists(path);\n    }\n\n    /// <inheritdoc/>\n    public override void CreateDirectory(string url)\n    {\n        var path = ConvertUrlToFullPath(url);\n        try\n        {\n            Directory.CreateDirectory(path);\n        }","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.IO/FileSystemProvider.cs#L44-L80","documentation":"ConvertFullPathToUrl converts an absolute local path back to a virtual URL by stripping the provider's base path. If the path does not live under localBasePath, the provider cannot map it back and throws instead of returning a wrong URL.","triggerScenarios":"Calling an API that resolves a local path to a URL (e.g. converting results of DirectoryExists/FileExists on a raw path) where the path was built outside the provider's base directory, or with different casing/drive prefix.","commonSituations":"Mixing absolute OS paths with virtual file system URLs, moving the base directory after provider creation, or on case-sensitive filesystems comparing with the wrong path form.","solutions":["Ensure the path passed is derived from the same provider's base path (e.g. via ConvertUrlToFullPath)","Recreate the FileSystemProvider with a base path that covers the file in question","Verify path casing/normalization matches (use Path.GetFullPath on both)"],"exampleFix":"// before\nvar url = provider.ConvertFullPathToUrl(\"/other/dir/file.txt\");\n// after\nvar local = provider.ConvertUrlToFullPath(\"mydir/file.txt\");\nvar url = provider.ConvertFullPathToUrl(local);","handlingStrategy":"validation","validationCode":"bool canConvert = localBasePath != null && path.StartsWith(localBasePath, StringComparison.OrdinalIgnoreCase);\nif (!canConvert) throw new InvalidOperationException($\"Path {path} is outside provider base {localBasePath}\");","typeGuard":null,"tryCatchPattern":"try { url = provider.ConvertFullPathToUrl(path); }\ncatch (InvalidOperationException) { url = path; /* path is outside this provider */ }","preventionTips":["Only convert paths produced by the same provider's ConvertUrlToFullPath","Normalize paths with Path.GetFullPath before comparison","Recreate providers when the base directory changes"],"tags":["io","path","virtual-filesystem"],"backgroundTag":"invalid-argument-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}