stride3d/stride · error · InvalidOperationException
Trying to convert back a path that is not in this file…
Error message
Trying to convert back a path that is not in this file system provider.
What it means
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.
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)
Example fix
// before
var url = provider.ConvertFullPathToUrl("/other/dir/file.txt");
// after
var local = provider.ConvertUrlToFullPath("mydir/file.txt");
var url = provider.ConvertFullPathToUrl(local); Defensive patterns
Strategy: validation
Validate before calling
bool canConvert = localBasePath != null && path.StartsWith(localBasePath, StringComparison.OrdinalIgnoreCase);
if (!canConvert) throw new InvalidOperationException($"Path {path} is outside provider base {localBasePath}"); Try / catch
try { url = provider.ConvertFullPathToUrl(path); }
catch (InvalidOperationException) { url = path; /* path is outside this provider */ } Prevention
- Only convert paths produced by the same provider's ConvertUrlToFullPath
- Normalize paths with Path.GetFullPath before comparison
- Recreate providers when the base directory changes
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Base path must be non-empty (use null for passthrough).
- Base path must be absolute, got
- assetItem must be an absolute path
- The relativePath argument is null or empty
- Expecting relative path
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/86c779ee400e8fc4.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.IO/FileSystemProvider.cs:62
// Ensure localBasePath ends with a \
if (localBasePath?.EndsWith(DirectorySeparatorChar) == false)
localBasePath += DirectorySeparatorChar;
}
protected virtual string ConvertUrlToFullPath(string url)
{
if (localBasePath == null)
return url;
return localBasePath + url.Replace(VirtualFileSystem.DirectorySeparatorChar, DirectorySeparatorChar);
}
protected virtual string ConvertFullPathToUrl(string path)
{
if (localBasePath == null)
return path;
if (!path.StartsWith(localBasePath, StringComparison.OrdinalIgnoreCase))
throw new InvalidOperationException("Trying to convert back a path that is not in this file system provider.");
return path[localBasePath.Length..].Replace(DirectorySeparatorChar, VirtualFileSystem.DirectorySeparatorChar);
}
public override bool DirectoryExists(string url)
{
var path = ConvertUrlToFullPath(url);
return Directory.Exists(path);
}
/// <inheritdoc/>
public override void CreateDirectory(string url)
{
var path = ConvertUrlToFullPath(url);
try
{
Directory.CreateDirectory(path);
}View on GitHub (pinned to 96fad776d2)