Skip to content

Expose HTTP response metadata on Dropbox exceptions - #482

Merged
AndreyVMarkelov merged 6 commits into
mainfrom
andreymarkelov/http-response-metadata
Nov 16, 2026
Merged

AndreyVMarkelov merged 6 commits into
mainfrom
andreymarkelov/http-response-metadata

Conversation

@AndreyVMarkelov

@AndreyVMarkelov AndreyVMarkelov commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

HTTP response status and headers are currently lost when the SDK raises an exception. This change exposes DropboxException.ResponseStatusCode (int?) and ResponseHeaders (IReadOnlyDictionary<string, IReadOnlyList<string>>) across RPC, upload, download, and OAuth refresh errors.

The transport captures a deeply read-only, case-insensitive snapshot of both response and content headers before disposal, preserving multiple values. Structured 409 errors carry the snapshot through the internal result. Retry exhaustion exposes the final response; existing request IDs, valid concrete exception types, constructors, messages, and retry policy remain unchanged.

Valid structured error decoding and lazy exception construction remain unchanged. Unexpected EOF inside an unfinished JSON object or array now raises JsonReaderException instead of allowing decoding to loop on a stale token. This includes truncated string arrays, nested arrays, and nullable elements. A structured error body of JSON null raises JsonReaderException instead of NullReferenceException. Unrelated decoder failures propagate unchanged; HTTP metadata is not guaranteed when decoding fails. No response objects, retry history, raw body API, or header logging are added.

Adds XML API documentation, a README example, and mocked-handler coverage for 400/401/403/404/409/418/422/429/500/503, all route styles, OAuth invalid_grant, disposal, immutability, malformed bodies, retry exhaustion, and body-based RetryAfter.

Fixes #38.

Validation

  • Full unit suite: 70 passed, 0 failed.
  • Release build for the supported netstandard2.0 target: 0 warnings, 0 errors.
  • dotnet format --verify-no-changes --severity warn on changed C# files: passed (workspace-loading warning).
  • git diff --check: passed.
  • Environment limitation: only .NET 10 runtime is installed; net8.0 tests ran with DOTNET_ROLL_FORWARD=Major. Local execution on the .NET 8 runtime and live integration tests was not performed. See the GitHub checks for the latest .NET 8 and live integration results.

Checklist

General Contributing

  • Have you read the Code of Conduct and signed the CLA?

Is This a Code Change?

  • Non-code related change (markdown/git settings etc)
  • SDK Code Change
  • Example/Test Code Change

Validation

  • Does this code build successfully?
  • Do all tests pass?
  • Does Stylecop pass?

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.98%. Comparing base (d89cf09) to head (5f8b769).

Files with missing lines Patch % Lines
...ox-sdk-dotnet/Dropbox.Api/DropboxRequestHandler.cs 92.45% 1 Missing and 3 partials ⚠️
dropbox-sdk-dotnet/Dropbox.Api/DropboxException.cs 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #482      +/-   ##
==========================================
+ Coverage   64.38%   68.98%   +4.59%     
==========================================
  Files          18       18              
  Lines        1696     1754      +58     
  Branches      159      166       +7     
==========================================
+ Hits         1092     1210     +118     
+ Misses        533      475      -58     
+ Partials       71       69       -2     
Flag Coverage Δ
integration 57.24% <74.11%> (+0.63%) ⬆️
unit 57.92% <94.11%> (+9.69%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AndreyVMarkelov
AndreyVMarkelov merged commit fc17d88 into main Nov 16, 2026
16 checks passed
@AndreyVMarkelov
AndreyVMarkelov deleted the andreymarkelov/http-response-metadata branch November 16, 2026 18:38
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.

Accessing Headers/Response on Execptions

2 participants