{"record":{"id":"7dc74598c47b4208","repo":"stride3d/stride","slug":"file-filepath-doesn-t-appear-to-be-a-valid-package","errorCode":null,"errorMessage":"File {filePath} doesn't appear to be a valid package","messagePattern":"File (.+?) doesn't appear to be a valid package","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/Package.cs","lineNumber":553,"sourceCode":"        bool hasPackage = false;\n        using (var reader = new StreamReader(stream))\n        {\n            string? line;\n            while ((line = reader.ReadLine()) is not null)\n            {\n                if (line.StartsWith(\"!Package\", StringComparison.Ordinal))\n                {\n                    hasPackage = true;\n                }\n\n                if (hasPackage && line.StartsWith(\"Id:\", StringComparison.Ordinal))\n                {\n                    var id = line[\"Id:\".Length..].Trim();\n                    return Guid.Parse(id);\n                }\n            }\n        }\n        throw new IOException($\"File {filePath} doesn't appear to be a valid package\");\n    }\n\n    /// <summary>\n    /// Loads only the package description but not assets or plugins.\n    /// </summary>\n    /// <param name=\"log\">The log to receive error messages.</param>\n    /// <param name=\"filePath\">The file path.</param>\n    /// <param name=\"loadParametersArg\">The load parameters argument.</param>\n    /// <returns>A package.</returns>\n    /// <exception cref=\"ArgumentNullException\">log\n    /// or\n    /// filePath</exception>\n    public static Package? Load(ILogger log, string filePath, PackageLoadParameters? loadParametersArg = null)\n    {\n        var package = LoadProject(log, filePath)?.Package;\n\n        if (package?.LoadAssembliesAndAssets(log, loadParametersArg) == false)\n        {","sourceCodeStart":535,"sourceCodeEnd":571,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/Package.cs#L535-L571","documentation":"Package.GetPackageIdFromFile reads the package file's sline header to extract the package Id GUID. If the Id line cannot be found or parsed before the file ends, it concludes the file is not a valid Stride package and throws IOException.","triggerScenarios":"Calling GetPackageIdFromFile on a file that lacks the \"Id:\" header line, has a corrupted/truncated header, or is not a .sdpkg/package file at all.","commonSituations":"Pointing at an empty or placeholder file; a package saved by an incompatible/older version; a text file renamed to .sdpkg; a partially written/downloaded package.","solutions":["Verify the file is a valid Stride package (.sdpkg) containing the Id: header line","Re-save or re-export the package from Stride Game Studio","Check the file is not truncated/corrupted (re-download or restore from VCS)"],"exampleFix":"// before\nvar id = Package.GetPackageIdFromFile(new UFile(\"notes.txt\"));\n// after\nif (File.Exists(path) && new FileInfo(path).Length > 0 && path.EndsWith(\".sdpkg\"))\n    var id = Package.GetPackageIdFromFile(new UFile(path));","handlingStrategy":"validation","validationCode":"if (!File.Exists(path) || !path.EndsWith(\".sdpkg\")) throw new FileNotFoundException(path);","typeGuard":null,"tryCatchPattern":"try { var id = Package.GetPackageIdFromFile(file); } catch (IOException ex) { log.Error($\"Not a valid package: {ex.Message}\"); }","preventionTips":["Validate package files come from trusted Stride exports","Check file size/content before parsing","Keep packages under version control to detect corruption"],"tags":["package","io","corruption"],"backgroundTag":"unexpected-response-shape","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"}