{"record":{"id":"27c7f02f2192587a","repo":"SubtitleEdit/subtitleedit","slug":"archive-contains-an-empty-file-entry-name","errorCode":null,"errorMessage":"Archive contains an empty file entry name.","messagePattern":"Archive contains an empty file entry name\\.","errorType":"validation","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"src/ui/Logic/SevenZipExtractor/Unpacker.cs","lineNumber":422,"sourceCode":"                    }\n                }\n\n                entryFullName = entryFullName.Replace('/', Path.DirectorySeparatorChar);\n                if (Path.IsPathRooted(entryFullName))\n                {\n                    throw new InvalidDataException($\"Archive entry is rooted outside the extraction folder: {reader.Entry.Key}\");\n                }\n\n                entryFullName = entryFullName.TrimStart(Path.DirectorySeparatorChar);\n                if (string.IsNullOrEmpty(entryFullName))\n                {\n                    if (reader.Entry.IsDirectory)\n                    {\n                        Directory.CreateDirectory(dir);\n                        continue;\n                    }\n\n                    throw new InvalidDataException(\"Archive contains an empty file entry name.\");\n                }\n\n                var fullFileName = Path.GetFullPath(Path.Combine(targetRoot, entryFullName));\n                var relativePath = Path.GetRelativePath(targetRoot, fullFileName);\n                if (relativePath.Equals(\"..\", StringComparison.Ordinal) ||\n                    relativePath.StartsWith(\"..\" + Path.DirectorySeparatorChar, StringComparison.Ordinal) ||\n                    Path.IsPathRooted(relativePath))\n                {\n                    throw new InvalidDataException($\"Archive entry is outside the extraction folder: {reader.Entry.Key}\");\n                }\n\n                if (reader.Entry.IsDirectory)\n                {\n                    if (!Directory.Exists(fullFileName))\n                    {\n                        Directory.CreateDirectory(fullFileName);\n                    }\n","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Logic/SevenZipExtractor/Unpacker.cs#L404-L440","documentation":"InvalidDataException: after stripping the leading separator and the optional skip-folder prefix, the entry name is empty AND the entry is not a directory, so it cannot be mapped to a real file path.","triggerScenarios":"An entry whose name is composed only of the skip-folder prefix or only of separators (no real filename), or a malformed archive exposing a file entry with an empty key.","commonSituations":"A malformed archive, or a skipFolderLevel value that consumes the entire entry name (mismatched archive layout vs. configuration).","solutions":["Verify the skipFolderLevel setting matches the archive's internal folder layout.","Reject the archive as malformed and re-export it correctly.","If authoring archives, ensure every file entry has a non-empty name after the intended prefix."],"exampleFix":"// before\nUnpacker.ExtractArchive(archivePath, dest, skipFolderLevel: \"payload\");\n\n// after\nif (DetectTopFolder(archivePath) != configuredSkipFolder) configuredSkipFolder = DetectTopFolder(archivePath);\nUnpacker.ExtractArchive(archivePath, dest, skipFolderLevel: configuredSkipFolder);","handlingStrategy":"validation","validationCode":"var detectedTop = DetectTopFolder(archive); if (detectedTop != configuredSkipFolder) configuredSkipFolder = detectedTop;","typeGuard":null,"tryCatchPattern":"try { Unpacker.ExtractArchive(archive, dest, skipFolderLevel: configuredSkipFolder); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"empty file entry name\"))\n{\n    logger.LogWarning(\"Malformed archive {Archive}; retrying without skip-folder\", archive);\n    Unpacker.ExtractArchive(archive, dest, skipFolderLevel: null);\n}","preventionTips":["Match skipFolderLevel to the archive's actual layout.","Reject malformed archives rather than weakening validation.","When authoring archives, ensure non-empty file entry names."],"tags":["archive","validation","malformed"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}