Skip to content

fix: return empty/null on 204 No Content and empty response bodies#1

Merged
H-Ashrafi merged 1 commit into
masterfrom
fix/empty-collection-204
May 13, 2026
Merged

fix: return empty/null on 204 No Content and empty response bodies#1
H-Ashrafi merged 1 commit into
masterfrom
fix/empty-collection-204

Conversation

@H-Ashrafi

Copy link
Copy Markdown
Contributor

Get* methods that returned collections (GetComputersAsync, GetProductsAsync, GetWebhooksAsync, GetWebhookDeliveriesAsync) called ReadFromJsonAsync unconditionally and threw
System.Text.Json.JsonException ("The input does not contain any JSON tokens") when the server returned HTTP 204 No Content or HTTP 200 with an empty body. The /api/computer/all endpoint returns 204 for receipts with zero attached computers, which crashed consumers that called GetComputersAsync.

Centralize the guard in two helpers (ReadJsonOrDefaultAsync, ReadJsonOrEmptyAsync) and route every affected Get* method through them so future endpoints inherit the fix.

Add an xUnit test project (LicenseManagement.Client.Tests) covering 204 and empty-body cases for the collection-returning Get* methods and the single-item GetComputerAsync.

Bumps package version to 1.2.1 (patch).

Get* methods that returned collections (GetComputersAsync,
GetProductsAsync, GetWebhooksAsync, GetWebhookDeliveriesAsync) called
ReadFromJsonAsync unconditionally and threw
System.Text.Json.JsonException ("The input does not contain any JSON
tokens") when the server returned HTTP 204 No Content or HTTP 200 with
an empty body. The /api/computer/all endpoint returns 204 for receipts
with zero attached computers, which crashed consumers that called
GetComputersAsync.

Centralize the guard in two helpers (ReadJsonOrDefaultAsync<T>,
ReadJsonOrEmptyAsync<T>) and route every affected Get* method through
them so future endpoints inherit the fix.

Add an xUnit test project (LicenseManagement.Client.Tests) covering 204
and empty-body cases for the collection-returning Get* methods and the
single-item GetComputerAsync.

Bumps package version to 1.2.1 (patch).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@H-Ashrafi H-Ashrafi merged commit f305450 into master May 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant