{"record":{"id":"7819fd96e0894fff","repo":"Devolutions/UniGetUI","slug":"the-bundle-content-could-not-be-parsed","errorCode":null,"errorMessage":"The bundle content could not be parsed.","messagePattern":"The bundle content could not be parsed\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/UniGetUI.Interface.IpcApi/IpcBundleApi.cs","lineNumber":608,"sourceCode":"\n    internal static async Task<(double SchemaVersion, BundleReport Report)> AddFromBundleAsync(\n        string content,\n        BundleFormatType format\n    )\n    {\n        if (format == BundleFormatType.YAML)\n        {\n            content = await SerializationHelpers.YAML_to_JSON(content);\n        }\n        else if (format == BundleFormatType.XML)\n        {\n            content = await SerializationHelpers.XML_to_JSON(content);\n        }\n\n        var deserializedData = await Task.Run(() =>\n            new SerializableBundle(\n                JsonNode.Parse(content)\n                    ?? throw new InvalidOperationException(\"The bundle content could not be parsed.\")\n            )\n        );\n\n        var report = new BundleReport { IsEmpty = true };\n        bool allowCliArguments =\n            SecureSettings.Get(SecureSettings.K.AllowCLIArguments)\n            && SecureSettings.Get(SecureSettings.K.AllowImportingCLIArguments);\n        bool allowPrePostCommands =\n            SecureSettings.Get(SecureSettings.K.AllowPrePostOpCommand)\n            && SecureSettings.Get(SecureSettings.K.AllowImportPrePostOpCommands);\n\n        List<IPackage> packages = [];\n        foreach (var package in deserializedData.packages)\n        {\n            var options = package.InstallationOptions;\n            ReportList(\n                ref report,\n                package.Id,","sourceCodeStart":590,"sourceCodeEnd":626,"githubUrl":"https://github.com/Devolutions/UniGetUI/blob/9b1d7d0eab91620fc15c86b36676532095936ae3/src/UniGetUI.Interface.IpcApi/IpcBundleApi.cs#L590-L626","documentation":"Thrown by IpcBundleApi.AddFromBundleAsync when JsonNode.Parse(content) returns null, i.e. the bundle payload (after optional YAML/XML-to-JSON conversion) is not valid parseable JSON. This is the import deserialization failure point; everything before it (format detection, file read, format conversion) succeeded.","triggerScenarios":"Importing a bundle file whose content is empty, whitespace-only, a JSON literal 'null', or structurally broken after YAML/XML conversion (e.g. a YAML-to-JSON conversion that produced an empty string). Also when request.Content is set to an invalid inline payload.","commonSituations":"A truncated/corrupt .ubundle backup (interrupted write, disk full). Hand-editing a JSON bundle and leaving a dangling comma. A YAML bundle whose converter emitted nothing. An empty file passed as the import source.","solutions":["Open the bundle file and validate it parses as JSON (e.g. 'python -m json.tool file.ubundle'); fix or regenerate it.","If the source was YAML/XML, check the converted intermediate JSON for emptiness before importing.","Re-export a fresh bundle from a running UniGetUI instance and replace the corrupt file.","Confirm the file was not zeroed out by a failed save (check file size > 0)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the bundle payload parses as JSON before importing.\nstatic async Task<bool> BundleParsesAsync(string path)\n{\n    var content = await File.ReadAllTextAsync(path);\n    if (string.IsNullOrWhiteSpace(content)) return false;\n    try { return JsonNode.Parse(content) is not null; }\n    catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try { await client.ImportBundleAsync(path, format); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"could not be parsed\"))\n{ /* treat as corrupt source file: regenerate or notify user */ }","preventionTips":["Validate bundle files parse as JSON before submitting them.","Keep backups of bundle files; do not overwrite the only copy during edits.","Re-export from a live instance when a file is suspected corrupt."],"tags":["ipc","bundle","import","serialization","corrupt-data"],"backgroundTag":null,"analyzedSha":"9b1d7d0eab91620fc15c86b36676532095936ae3","analyzedAt":"2026-08-13T12:19:18.278Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}