{"record":{"id":"54691fb0cf9948c8","repo":"Devolutions/UniGetUI","slug":"bundle-export-only-supports-ubundle-and-json-out","errorCode":null,"errorMessage":"Bundle export only supports .ubundle and .json output files.","messagePattern":"Bundle export only supports \\.ubundle and \\.json output files\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/UniGetUI.Interface.IpcApi/IpcBundleApi.cs","lineNumber":523,"sourceCode":"            return BundleFormatType.UBUNDLE;\n        }\n\n        return ParseFormat(Path.GetExtension(request.Path));\n    }\n\n    private static BundleFormatType ResolveExportFormat(string? path)\n    {\n        if (string.IsNullOrWhiteSpace(path))\n        {\n            return BundleFormatType.UBUNDLE;\n        }\n\n        var extension = Path.GetExtension(path);\n        return extension.ToLowerInvariant() switch\n        {\n            \".json\" => BundleFormatType.JSON,\n            \".ubundle\" or \"\" => BundleFormatType.UBUNDLE,\n            _ => throw new InvalidOperationException(\n                \"Bundle export only supports .ubundle and .json output files.\"\n            ),\n        };\n    }\n\n    private static BundleFormatType ParseFormat(string? format)\n    {\n        return format?.Trim().TrimStart('.').ToLowerInvariant() switch\n        {\n            null or \"\" or \"ubundle\" => BundleFormatType.UBUNDLE,\n            \"json\" => BundleFormatType.JSON,\n            \"yaml\" or \"yml\" => BundleFormatType.YAML,\n            \"xml\" => BundleFormatType.XML,\n            _ => throw new InvalidOperationException(\n                $\"The bundle format \\\"{format}\\\" is not supported.\"\n            ),\n        };\n    }","sourceCodeStart":505,"sourceCodeEnd":541,"githubUrl":"https://github.com/Devolutions/UniGetUI/blob/9b1d7d0eab91620fc15c86b36676532095936ae3/src/UniGetUI.Interface.IpcApi/IpcBundleApi.cs#L505-L541","documentation":"Thrown by IpcBundleApi.ResolveExportFormat when exporting a bundle to a file whose extension is neither '.json', '.ubundle', nor empty. Note the asymmetry: import (ParseFormat) accepts yaml/yml/xml too, but export is intentionally limited to ubundle and json because those are the only serialization paths the export writer implements.","triggerScenarios":"Calling the bundle export IPC endpoint (or CLI 'bundle export') with a --path argument whose extension is something other than .json/.ubundle (e.g. '--path backup.yaml', '--path backup.xml', '--path backup.txt'). ResolveExportFormat reads Path.GetExtension and falls to the default switch arm.","commonSituations":"A user who successfully imported a .yaml bundle assumes they can re-export to the same format. Scripting a backup pipeline that normalizes all outputs to one extension (e.g. .bak) without realizing export rejects it. Copying an import flag set (--format yaml) into an export command.","solutions":["Change the export --path to end in .ubundle (or omit the extension, which defaults to ubundle).","If you need JSON output, name the file with a .json extension.","If you require yaml/xml output, first export to .json/.ubundle then convert with an external tool; the IPC API export path does not support it."],"exampleFix":"// before\nunigetui bundle export --path ~/backups/pkg-set.yaml\n// after\nunigetui bundle export --path ~/backups/pkg-set.ubundle","handlingStrategy":"validation","validationCode":"static bool IsValidExportPath(string? path) =>\n    string.IsNullOrWhiteSpace(path)\n    || Path.GetExtension(path).ToLowerInvariant() is \".json\" or \".ubundle\" or \"\";\n\n// call before export:\nif (!IsValidExportPath(request.Path))\n    throw new ArgumentException(\"Export path must end in .ubundle or .json\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize export-path validation in the caller before hitting the IPC boundary.","Remember export supports fewer formats than import; do not reuse import format lists for export.","Default the export path to a .ubundle extension when none is given."],"tags":["ipc","bundle","export","file-format","input-validation"],"backgroundTag":null,"analyzedSha":"9b1d7d0eab91620fc15c86b36676532095936ae3","analyzedAt":"2026-08-13T12:19:18.278Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}