{"record":{"id":"be2567ff0b32c641","repo":"stride3d/stride","slug":"file-not-found-inside-zip-archive","errorCode":null,"errorMessage":"File not found inside ZIP archive.","messagePattern":"File not found inside ZIP archive\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.IO/ZipFileSystemProvider.cs","lineNumber":65,"sourceCode":"        {\n            if (!zipFileEntries.TryGetValue(path, out var zipFileEntry) || zipFileEntry.Method != Compression.Store)\n            {\n                filePath = null;\n                start = 0;\n                end = -1;\n                return false;\n            }\n\n            filePath = zipFile.FileName;\n            start = zipFileEntry.FileOffset;\n            end = zipFileEntry.FileOffset + zipFileEntry.FileSize;\n            return true;\n        }\n\n        public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamType = StreamFlags.None)\n        {\n            if (!zipFileEntries.TryGetValue(url, out var zipFileEntry))\n                throw new FileNotFoundException(\"File not found inside ZIP archive.\");\n\n            if (mode != VirtualFileMode.Open || access != VirtualFileAccess.Read)\n                throw new UnauthorizedAccessException(\"ZIP archive are read-only.\");\n\n            lock (zipFile)\n            {\n                if (zipFileEntry.Method == Compression.Store)\n                {\n                    // Open a VirtualFileStream on top of Zip FileStream\n                    return new VirtualFileStream(new FileStream(zipFileEntry.ZipFileName, FileMode.Open, FileAccess.Read), zipFileEntry.FileOffset, zipFileEntry.FileOffset + zipFileEntry.FileSize);\n                }\n\n                // Decompress it into a MemoryStream\n                var buffer = new byte[zipFileEntry.FileSize];\n                zipFile.ExtractFile(zipFileEntry, buffer);\n                return new MemoryStream(buffer);\n            }\n        }","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.IO/ZipFileSystemProvider.cs#L47-L83","documentation":"ZipFileSystemProvider.OpenStream looks up the requested URL in the ZIP's entry table (zipFileEntries). When the entry is absent, a FileNotFoundException is thrown because the file does not exist inside the archive. The check happens before mode/access validation.","triggerScenarios":"Opening a stream for a URL that is not an entry in the ZIP: wrong path/casing, file missing from the archive, or the URL was never passed through the provider's own URL mapping (e.g. absolute local path instead of archive-relative).","commonSituations":"Corrupt or partially uploaded ZIP assets; file renamed in the archive but not in code; case-sensitive lookups failing on mixed-case URLs; loading bundled resources after a packaging step omitted the file.","solutions":["Check provider.FileExists(url) before calling OpenStream.","Verify the URL exists in the archive (list entries via ListFiles) and match exact casing/path.","Repackage/re-upload the ZIP ensuring the required entry is included.","Wrap in try-catch FileNotFoundException to handle optional files gracefully."],"exampleFix":"// before\nusing var s = zipProvider.OpenStream(url, VirtualFileMode.Open, VirtualFileAccess.Read);\n// after\nif (!zipProvider.FileExists(url))\n    throw new FileNotFoundException($\"{url} missing from ZIP archive.\", url);\nusing var s = zipProvider.OpenStream(url, VirtualFileMode.Open, VirtualFileAccess.Read);","handlingStrategy":"validation","validationCode":"if (!zipProvider.FileExists(url))\n    throw new FileNotFoundException($\"Entry '{url}' not present in ZIP archive.\", url);","typeGuard":null,"tryCatchPattern":"try { stream = zipProvider.OpenStream(url, VirtualFileMode.Open, VirtualFileAccess.Read); }\ncatch (FileNotFoundException) { stream = null; /* fall back to alternate source */ }","preventionTips":["Verify archive contents after packaging (manifest check)","Match URL casing exactly; keep a single URL builder","Wrap ZIP loads in try-catch with a fallback download/repackage path"],"tags":["filesystem","zip","file-not-found"],"backgroundTag":"file-not-found","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"}