abpframework/abp · error · AbpException

Failed to deserialize the created storage zone response for

Error message

Failed to deserialize the created storage zone response for '{containerName}'

What it means

Thrown by DefaultBunnyClientFactory.CreateStorageZoneAsync when the storage-zone creation POST succeeded (2xx) but JsonSerializer.Deserialize<BunnyStorageZoneModel> returned null for the response body. It indicates the Bunny API returned an unexpected or empty body that does not deserialize into the expected zone model. The exception names the containerName whose creation response could not be parsed.

Source

Thrown at framework/src/Volo.Abp.BlobStoring.Bunny/Volo/Abp/BlobStoring/Bunny/DefaultBunnyClientFactory.cs:131

            var response = await client.PostAsync(
                "https://api.bunny.net/storagezone",
                content);

            if (!response.IsSuccessStatusCode)
            {
                var errorContent = await response.Content.ReadAsStringAsync();
                throw new AbpException(
                    $"Failed to create storage zone '{containerName}'. " +
                    $"Status: {response.StatusCode}, Error: {errorContent}");
            }

            var responseContent = await response.Content.ReadAsStringAsync();
            var createdZone = JsonSerializer.Deserialize<BunnyStorageZoneModel>(responseContent);

            if (createdZone == null)
            {
                throw new AbpException($"Failed to deserialize the created storage zone response for '{containerName}'");
            }

            return createdZone;
        }
    }

    protected virtual async Task<BunnyStorageZoneModel?> GetStorageZoneAsync(string accessKey, string containerName)
    {
        using (var client = _httpClientFactory.CreateClient("BunnyApiClient"))
        {
            client.DefaultRequestHeaders.Add("AccessKey", accessKey);
            var response = await client.GetAsync("https://api.bunny.net/storagezone");
            response.EnsureSuccessStatusCode();

            var content = await response.Content.ReadAsStringAsync();
            var zones = JsonSerializer.Deserialize<BunnyStorageZoneModel[]>(content);

            return zones?.FirstOrDefault(x => x.Name.Equals(containerName, StringComparison.OrdinalIgnoreCase) && !x.Deleted);

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Check the Bunny dashboard: the zone may already exist (creation succeeded); remove CreateContainerIfNotExists or point at the existing zone.
  2. Verify the BunnyStorageZoneModel matches the current Bunny API response schema; update the model/SDK if the API changed.
  3. Capture and inspect the raw response body to diagnose the schema mismatch.
  4. As a workaround, create the zone manually in the dashboard and disable auto-creation.

Example fix

// The zone likely exists server-side; switch off auto-create and reuse it
"Bunny": {
  "AccessKey": "<key>",
  "ContainerName": "my-zone",
  "CreateContainerIfNotExists": false
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Prefer pre-existing zones to avoid relying on response deserialization:
configuration.CreateContainerIfNotExists = false;
// ensure the zone already exists in Bunny before operating

Type guard

bool reliesOnAutoCreate = configuration.CreateContainerIfNotExists; // this error only occurs during auto-create

Try / catch

try { await container.SaveAsync(blobName, stream); }
catch (AbpException ex) when (ex.Message.Contains("Failed to deserialize"))
{
    // zone may exist server-side; check Bunny dashboard, then disable auto-create
    configuration.CreateContainerIfNotExists = false;
}

Prevention

When it happens

Trigger: A successful POST to the Bunny storagezone endpoint whose JSON body is empty, null, or structurally incompatible with BunnyStorageZoneModel, so the deserialized result is null. This breaks the auto-create flow after the zone is nominally created.

Common situations: Bunny API contract change altering the response shape, an empty 200/201 body, or a version mismatch between the expected BunnyStorageZoneModel and the actual API response. The zone may actually have been created server-side.

Related errors


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/2053a09474d43d3b. Report an issue: GitHub.