stride3d/stride · error · FileNotFoundException

Unable to find the file

Error message

Unable to find the file [{url}]

What it means

DatabaseFileProvider.OpenStream resolves a URL to an ObjectId via the object database's index map before opening the stream. When the URL cannot be parsed as an ObjectId reference and TryGetObjectId cannot find it in the index, a FileNotFoundException is thrown, indicating the file is not present in the mounted asset database.

Solutions

  1. Verify the URL exists in the index (e.g. via IContentIndexMap / TryGetObjectId) before opening
  2. Check the URL spelling and that the correct database/mount path is used
  3. Rebuild or re-save the asset index if it is stale or truncated
  4. Re-add the missing asset to the object database

Example fix

// before
using var s = provider.OpenStream(url, StreamMode.Read, StreamFlags.Seekable);
// after
if (((IContentIndexMap)indexMap).TryGetValue(url, out _))
    using var s = provider.OpenStream(url, StreamMode.Read, StreamFlags.Seekable);
else
    Log.Warning($"Asset '{url}' not found in database");
Defensive patterns

Strategy: try-catch

Validate before calling

bool Exists(IContentIndexMap map, string url) =>
    map.TryGetValue(url, out _);

Try / catch

try
{
    using var stream = provider.OpenStream(url, StreamMode.Read, StreamFlags.Seekable);
    // use stream
}
catch (FileNotFoundException)
{
    Log.Warning($"Asset '{url}' missing from database");
}

Prevention

When it happens

Trigger: Opening a stream for a URL that was never written to the database, a misspelled/renamed asset URL, or a URL whose entry is missing from the index map (e.g. stale or truncated index file).

Common situations: Requesting assets deleted from the asset store; case/path mismatches between recorded and requested URLs; corrupted index files after a crash; code built against one database opened with another.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/3b1889f9c9bd7925. Report an issue: GitHub.

Appendix: source

Thrown at sources/core/Stride.Core.Serialization/IO/DatabaseFileProvider.cs:61

    public IContentIndexMap ContentIndexMap { get; }

    public ObjectDatabase ObjectDatabase { get; }

    /// <inheritdoc/>
    public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamFlags = StreamFlags.None)
    {
        // Open or create the file through the underlying (IContentIndexMap, IOdbBackend) couple.
        // Also read/write a ObjectHeader.
        if (mode == VirtualFileMode.Open)
        {
            ObjectId objectId;
            if (url.StartsWith(ObjectIdUrl, StringComparison.Ordinal))
            {
                _ = ObjectId.TryParse(url[ObjectIdUrl.Length..], out objectId);
            }
            else if (!TryGetObjectId(url, out objectId))
            {
                throw new FileNotFoundException($"Unable to find the file [{url}]");
            }

            var result = ObjectDatabase.OpenStream(objectId, mode, access, share);

            // copy the stream into a memory stream in order to make it seek-able
            if (streamFlags == StreamFlags.Seekable && !result.CanSeek)
            {
                var buffer = new byte[result.Length - result.Position];
                result.ReadExactly(buffer, 0, buffer.Length);
                return new DatabaseReadFileStream(objectId, new MemoryStream(buffer), 0);
            }

            return new DatabaseReadFileStream(objectId, result, result.Position);
        }

        if (mode == VirtualFileMode.Create)
        {
            if (url.StartsWith(ObjectIdUrl, StringComparison.Ordinal))

View on GitHub (pinned to 96fad776d2)