{"record":{"id":"748afb9b7a14a0c3","repo":"SubtitleEdit/subtitleedit","slug":"ebu-header-file-not-found-ebuheaderfile","errorCode":null,"errorMessage":"EBU header file not found: {ebuHeaderFile}","messagePattern":"EBU header file not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/seconv/Core/LibSEIntegration.cs","lineNumber":476,"sourceCode":"        {\n            targetFormat.RemoveNativeFormatting(subtitle, sourceFormat);\n        }\n\n        var outputDir = Path.GetDirectoryName(filePath);\n        if (!string.IsNullOrEmpty(outputDir) && !Directory.Exists(outputDir))\n        {\n            Directory.CreateDirectory(outputDir);\n        }\n\n        // Ebu (binary) — optional header file\n        if (targetFormat is Ebu ebu)\n        {\n            Ebu.EbuGeneralSubtitleInformation? header = null;\n            if (!string.IsNullOrEmpty(ebuHeaderFile))\n            {\n                if (!File.Exists(ebuHeaderFile))\n                {\n                    throw new FileNotFoundException($\"EBU header file not found: {ebuHeaderFile}\", ebuHeaderFile);\n                }\n                var headerBytes = File.ReadAllBytes(ebuHeaderFile);\n                header = Ebu.ReadHeader(headerBytes);\n            }\n            ebu.Save(filePath, subtitle, true, header);\n            return;\n        }\n\n        // Pac and PacUnicode (binary) — optional code page\n        if (targetFormat is Pac pac)\n        {\n            if (pacCodePage.HasValue)\n            {\n                pac.CodePage = pacCodePage.Value;\n            }\n            pac.Save(filePath, subtitle);\n            return;\n        }","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/seconv/Core/LibSEIntegration.cs#L458-L494","documentation":"Thrown when the target format is EBU (binary .stl) and an EBU header file path was supplied via ebuHeaderFile, but that file does not exist (File.Exists returns false). The EBU format optionally uses a pre-built EbuGeneralSubtitleInformation header to control STL metadata; when specified it must be readable. The exception is a FileNotFoundException with the path as FileName.","triggerScenarios":"Calling the EBU save path with a non-null, non-empty ebuHeaderFile argument that does not resolve to an existing file. The file may have been moved, the path mistyped, or resolved relative to the wrong working directory.","commonSituations":"CLI --ebu-header pointing to a deleted or relocated file; a relative path in a script that breaks when CWD changes; sharing a config that references a machine-specific header file path.","solutions":["Verify the header file path with File.Exists before calling Save; if it is optional, omit it entirely when the file is absent.","Resolve the path to an absolute path with Path.GetFullPath to avoid CWD ambiguity.","If the header file was lost, regenerate it from the Subtitle Edit GUI EBU export dialog, or omit it to use LibSE's default header."],"exampleFix":"// before\nLibSEIntegration.SaveSubtitle(sub, outPath, \"EBU\", options, ebuHeaderFile: headerPath);\n\n// after\nif (!string.IsNullOrEmpty(headerPath) && !File.Exists(headerPath))\n    throw new FileNotFoundException($\"EBU header file not found: {headerPath}\");\nLibSEIntegration.SaveSubtitle(sub, outPath, \"EBU\", options, ebuHeaderFile: headerPath);","handlingStrategy":"validation","validationCode":"if (!string.IsNullOrEmpty(ebuHeaderFile) && !File.Exists(ebuHeaderFile))\n    throw new FileNotFoundException($\"EBU header file not found: {ebuHeaderFile}\", ebuHeaderFile);","typeGuard":"static bool IsEbuHeaderReadable(string path) => string.IsNullOrEmpty(path) || File.Exists(path);","tryCatchPattern":"try { LibSEIntegration.SaveSubtitle(sub, outPath, \"EBU\", options, ebuHeaderFile: headerPath); }\ncatch (FileNotFoundException ex) when (ex.Message.Contains(\"EBU header file not found\"))\n{ /* omit header or supply correct path */ }","preventionTips":["Treat the EBU header file as optional — omit it when not needed rather than passing a possibly-wrong path.","Validate File.Exists for optional file arguments before passing them.","Store header templates in a known, version-controlled location."],"tags":["file-not-found","ebu","validation","path","subtitles"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}