Devolutions/UniGetUI · error · InvalidOperationException

The GitHub backup gist could not be created.

Error message

The GitHub backup gist could not be created.

What it means

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.

Source

Thrown at src/UniGetUI.Interface.IpcApi/IpcBackupApi.cs:304

                Key = file.Key.Split(' ')[^1],
                Display = file.Key.Split(' ')[^1] + " (" + CoreTools.FormatAsSize(file.Value.Size) + ")",
                IsCurrentMachine = file.Key.Split(' ')[^1].Equals(
                    currentMachineKey,
                    StringComparison.OrdinalIgnoreCase
                ),
            })
            .OrderBy(file => file.Key, StringComparer.OrdinalIgnoreCase)
            .ToArray();
    }

    public static async Task<IpcCloudBackupUploadResult> CreateCloudBackupAsync()
    {
        var packages = GetInstalledPackagesForBackup();
        string bundleContents = await IpcBundleApi.CreateBundleAsync(packages);
        using var client = CreateAuthenticatedGitHubClient();
        await GetAuthenticatedGitHubUserAsync(client);
        var backupGist = await GetBackupGistAsync(client, createIfMissing: true)
            ?? throw new InvalidOperationException("The GitHub backup gist could not be created.");

        string fileKey = BuildGistFileKey();
        await client.EditGistAsync(
            backupGist.Id,
            GistDescription,
            new Dictionary<string, string> { [fileKey] = bundleContents }
        );
        return new IpcCloudBackupUploadResult
        {
            Status = "success",
            Command = "create-cloud-backup",
            Key = fileKey.Split(' ')[^1],
            PackageCount = packages.Count,
        };
    }

    public static async Task<IpcCloudBackupContentResult> DownloadCloudBackupAsync(
        IpcCloudBackupRequest request

View on GitHub (pinned to 9b1d7d0eab)

Solutions

  1. Retry CreateCloudBackupAsync — a null gist on creation is usually transient.
  2. Check the GitHub API status for ongoing issues with gist creation.
  3. Verify the authenticated user has gist scope (the device flow requested read:user and gist).
  4. Inspect logs for any HttpRequestException or JSON deserialization warnings from the gist creation call.
Defensive patterns

Strategy: retry

Try / catch

try { await IpcBackupApi.CreateCloudBackupAsync(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("could not be created"))
{ /* transient GitHub API issue; retry after a short delay */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Devolutions/UniGetUI@9b1d7d0eab (2026-08-13). Data as JSON: /api/errors/3dfbfa5c62f6cc80. Report an issue: GitHub.