fix: include request URL in NetworkException#31
Merged
Conversation
NetworkException previously surfaced only the status code and response body, so callers wrapping the SDK could not tell whether a 401 came from PKG (MPK / signing-key fetch) or one of the three Cryptify upload phases without digging through stack traces. Add a Url property, include the URL in the message, and propagate it from both EnsureSuccessAsync helpers via response.RequestMessage.RequestUri. Closes #26
Contributor
Author
There was a problem hiding this comment.
LGTM — would approve, but GitHub blocks self-approval on bot-authored PRs.
Implementation matches the suggested fix in #26 one-for-one: Url property added, both EnsureSuccessAsync helpers (src/Api/PkgClient.cs:71, src/Api/CryptifyClient.cs:131) read response.RequestMessage?.RequestUri with a <unknown> fallback, and message format becomes HTTP {status} at {url}: {body}.
Checked:
- Correctness — all five failure sites (
FetchMpkJsonAsync,FetchSigningKeysAsync,InitUploadAsync,StoreChunkAsync,FinalizeUploadAsync) pick up the URL transparently viaHttpClient's auto-setRequestMessage. - Security — none of the constructed URLs carry auth tokens or query strings; bearer/
cryptifytokenlive in headers. The UUID path segment in the Cryptify upload URLs is operationally fine to surface in exception messages. - Null safety —
?.chain +??fallback covers a missingRequestMessage/RequestUri. - Tests — three new xUnit cases (
NetworkExceptionTests) cover property population, message formatting, and empty body; 25/25 pass on net10.0 locally. CI net8.0 + net10.0 both pass. - API surface — constructor signature change is breaking in theory, but
NetworkExceptionis thrown by the SDK and not meant for consumer construction; pre-1.0 release-please flow handles this underfix:. - Build clean, no warnings.
Ready to merge.
rubenhensen
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the request URL to
NetworkExceptionso callers wrapping this SDK can tell PKG vs Cryptify failures (and which Cryptify phase) apart without spelunking through stack traces.NetworkExceptiongains aUrlproperty; constructor signature is now(int statusCode, string body, string url).HTTP {status} at {url}: {body}(e.g.HTTP 401 at https://pkg.postguard.eu/v2/irma/sign/key: Unauthorized).EnsureSuccessAsynchelpers (PkgClient,CryptifyClient) readresponse.RequestMessage?.RequestUri— set automatically byHttpClient— and pass it through. No per-call-site plumbing needed; all five failure sites (FetchMpkJsonAsync,FetchSigningKeysAsync,InitUploadAsync,StoreChunkAsync,FinalizeUploadAsync) gain context for free.NetworkExceptionTests(3 xUnit cases) covering the new property, message formatting, and an empty-body sanity case.Closes #26
Test plan
dotnet build— net8.0 + net10.0, no warningsdotnet test— 25/25 pass on net10.0 (net8.0 runtime not installed in this workspace; CI will exercise it)