{"record":{"id":"05a3c920bd41e288","repo":"Devolutions/UniGetUI","slug":"exactly-one-of-content-or-path-must-be-supplied-wh","errorCode":null,"errorMessage":"Exactly one of content or path must be supplied when importing a bundle.","messagePattern":"Exactly one of content or path must be supplied when importing a bundle\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"src/UniGetUI.Interface.IpcApi/IpcBundleApi.cs","lineNumber":483,"sourceCode":"            return (await imported.AsSerializableAsync()).Version;\n        }\n\n        if (package is InvalidImportedPackage invalid)\n        {\n            return invalid.AsSerializable_Incompatible().Version;\n        }\n\n        return package.VersionString;\n    }\n\n    private static async Task<string> ReadBundleContentAsync(IpcBundleImportRequest request)\n    {\n        bool hasContent = !string.IsNullOrWhiteSpace(request.Content);\n        bool hasPath = !string.IsNullOrWhiteSpace(request.Path);\n\n        if (hasContent == hasPath)\n        {\n            throw new InvalidOperationException(\n                \"Exactly one of content or path must be supplied when importing a bundle.\"\n            );\n        }\n\n        if (hasContent)\n        {\n            return request.Content!;\n        }\n\n        return await File.ReadAllTextAsync(request.Path!);\n    }\n\n    private static BundleFormatType ResolveImportFormat(IpcBundleImportRequest request)\n    {\n        if (!string.IsNullOrWhiteSpace(request.Format))\n        {\n            return ParseFormat(request.Format);\n        }","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/Devolutions/UniGetUI/blob/9b1d7d0eab91620fc15c86b36676532095936ae3/src/UniGetUI.Interface.IpcApi/IpcBundleApi.cs#L465-L501","documentation":"ReadBundleContentAsync (called by ImportBundleAsync) requires exactly one source for the bundle data: either request.Content (inline string) or request.Path (file path). It computes hasContent and hasPath as non-whitespace checks and throws InvalidOperationException when both are true (ambiguous) or both are false (nothing to import). This is a mutually-exclusive input contract.","triggerScenarios":"An IpcBundleImportRequest is passed to ImportBundleAsync where both Content and Path are set (ambiguous), or both are null/empty/whitespace (no data). The XOR condition hasContent == hasPath catches both cases: true==true (both set) and false==false (neither set).","commonSituations":"A client sends both an inline content blob and a file path, expecting the API to pick one. A client sends neither, expecting a file dialog or default. A UI form populates both fields. A serialization issue leaves both fields null when one should have been set.","solutions":["Set exactly one of request.Content or request.Path; leave the other null.","If importing from a file, set Path and leave Content null.","If importing inline JSON/YAML/XML, set Content and leave Path null.","Validate the XOR condition client-side before calling ImportBundleAsync."],"exampleFix":"// before: both fields set (ambiguous)\nawait IpcBundleApi.ImportBundleAsync(new IpcBundleImportRequest { Content = json, Path = \"/tmp/b.ubundle\" });\n// after: exactly one source\nawait IpcBundleApi.ImportBundleAsync(new IpcBundleImportRequest { Content = json });\n// or\nawait IpcBundleApi.ImportBundleAsync(new IpcBundleImportRequest { Path = \"/tmp/b.ubundle\" });","handlingStrategy":"validation","validationCode":"bool hasContent = !string.IsNullOrWhiteSpace(request.Content);\nbool hasPath = !string.IsNullOrWhiteSpace(request.Path);\nif (hasContent == hasPath)\n    throw new ArgumentException(\"Provide exactly one of Content or Path.\");","typeGuard":"static bool HasExactlyOneBundleSource(IpcBundleImportRequest r)\n{\n    bool c = !string.IsNullOrWhiteSpace(r.Content);\n    bool p = !string.IsNullOrWhiteSpace(r.Path);\n    return c ^ p;\n}","tryCatchPattern":"try { await IpcBundleApi.ImportBundleAsync(request); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"content or path\"))\n{ /* client must set exactly one field */ }","preventionTips":["Set exactly one of Content or Path in IpcBundleImportRequest; null the other.","Validate the XOR condition client-side before sending.","Use Content for inline imports and Path for file imports."],"tags":["bundle","import","validation","ipc","client-error"],"backgroundTag":null,"analyzedSha":"9b1d7d0eab91620fc15c86b36676532095936ae3","analyzedAt":"2026-08-13T12:19:18.278Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}