{"record":{"id":"3dfbfa5c62f6cc80","repo":"Devolutions/UniGetUI","slug":"the-github-backup-gist-could-not-be-created","errorCode":null,"errorMessage":"The GitHub backup gist could not be created.","messagePattern":"The GitHub backup gist could not be created\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/UniGetUI.Interface.IpcApi/IpcBackupApi.cs","lineNumber":304,"sourceCode":"                Key = file.Key.Split(' ')[^1],\n                Display = file.Key.Split(' ')[^1] + \" (\" + CoreTools.FormatAsSize(file.Value.Size) + \")\",\n                IsCurrentMachine = file.Key.Split(' ')[^1].Equals(\n                    currentMachineKey,\n                    StringComparison.OrdinalIgnoreCase\n                ),\n            })\n            .OrderBy(file => file.Key, StringComparer.OrdinalIgnoreCase)\n            .ToArray();\n    }\n\n    public static async Task<IpcCloudBackupUploadResult> CreateCloudBackupAsync()\n    {\n        var packages = GetInstalledPackagesForBackup();\n        string bundleContents = await IpcBundleApi.CreateBundleAsync(packages);\n        using var client = CreateAuthenticatedGitHubClient();\n        await GetAuthenticatedGitHubUserAsync(client);\n        var backupGist = await GetBackupGistAsync(client, createIfMissing: true)\n            ?? throw new InvalidOperationException(\"The GitHub backup gist could not be created.\");\n\n        string fileKey = BuildGistFileKey();\n        await client.EditGistAsync(\n            backupGist.Id,\n            GistDescription,\n            new Dictionary<string, string> { [fileKey] = bundleContents }\n        );\n        return new IpcCloudBackupUploadResult\n        {\n            Status = \"success\",\n            Command = \"create-cloud-backup\",\n            Key = fileKey.Split(' ')[^1],\n            PackageCount = packages.Count,\n        };\n    }\n\n    public static async Task<IpcCloudBackupContentResult> DownloadCloudBackupAsync(\n        IpcCloudBackupRequest request","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/Devolutions/UniGetUI/blob/9b1d7d0eab91620fc15c86b36676532095936ae3/src/UniGetUI.Interface.IpcApi/IpcBackupApi.cs#L286-L322","documentation":"CreateCloudBackupAsync calls GetBackupGistAsync with createIfMissing=true. That helper searches the user's gists for one whose description ends with the sentinel ending key; if not found and createIfMissing is true, it calls CreateGistAsync. If CreateGistAsync returns null (empty deserialized response), GetBackupGistAsync returns null, and the null-coalescing throw fires with InvalidOperationException. This indicates GitHub accepted the gist creation request (2xx) but returned an empty/null body.","triggerScenarios":"The user has no existing backup gist. GetBackupGistAsync attempts to create one via CreateGistAsync (POST /gists). GitHub returns a success status but the response body deserializes to null, so the gist reference is null. This is typically a transient API anomaly or a schema mismatch.","commonSituations":"Transient GitHub API issue returns an empty body on gist creation. The gist creation payload was accepted but the response was truncated by a proxy. The GitHub API schema changed and the source-generated deserializer could not populate the gist object. Rate limiting returned a 2xx with an unusual body.","solutions":["Retry CreateCloudBackupAsync — a null gist on creation is usually transient.","Check the GitHub API status for ongoing issues with gist creation.","Verify the authenticated user has gist scope (the device flow requested read:user and gist).","Inspect logs for any HttpRequestException or JSON deserialization warnings from the gist creation call."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await IpcBackupApi.CreateCloudBackupAsync(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"could not be created\"))\n{ /* transient GitHub API issue; retry after a short delay */ }","preventionTips":["Retry cloud-backup creation once on this transient error.","Confirm the authenticated user has gist scope.","Check GitHub API status if gist creation persistently returns empty."],"tags":["github","backup","gist","api","ipc"],"backgroundTag":null,"analyzedSha":"9b1d7d0eab91620fc15c86b36676532095936ae3","analyzedAt":"2026-08-13T12:19:18.278Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}