Skip to content

Fix RestAPI IApiResponse disposing the HTTP response before the caller owns it - #214

Merged
Skymly merged 1 commit into
mainfrom
fix/restapi-response-ownership
Aug 20, 2026
Merged

Fix RestAPI IApiResponse disposing the HTTP response before the caller owns it#214
Skymly merged 1 commit into
mainfrom
fix/restapi-response-ownership

Conversation

@Skymly

@Skymly Skymly commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Summary

IApiResponse already owns the HttpResponseMessage via IDisposable, but RestApiBridge.SendAsync disposed that response in finally before the caller could use it.

This PR transfers ownership when returning the wrapper, rethrows caller cancellation instead of wrapping it as ApiRequestException, and coerces non-ApiExceptionBase ExceptionFactory results so Error and IsSuccessful stay consistent.

Related Issue

Fixes #213

Parent map: #212

Solution module

  • RestAPI

Type of change

  • Bug fix

Test plan

  • dotnet test Observables.RestAPI/Observables.RestAPI.Tests/Observables.RestAPI.Tests.csproj (net8.0 and net10.0: 9 passed). net9.0 failed locally with a missing apphost.exe copy (SDK/obj), unrelated to this change.

Breaking changes

  • None as a version bump. Caller cancellation on IApiResponse now throws OperationCanceledException instead of returning a wrapper with Error (aligned with the existing deserialize path). Timeout-like cancel on SendAsync is still ApiRequestException. SendVoidAsync is unchanged.

Checklist

  • This PR touches only one solution module (see AGENTS.md)
  • Commit messages are in English (no AI/agent tooling mentions in commits)
  • No version bumps, tags, releases, or NuGet publish steps included unless explicitly requested
  • Design Doc updated if API / diagnostic / implementation changed
  • Observables.Docs / Samples synced if user-visible (separate PRs)
  • No documentation changes in this PR — docs/design/restapi.md is the Docs module (follow-up from Wayfinder: post-0.2.0 bug hunt and shallow-module deepening #212)

…r owns it.

Transfer ownership when returning the wrapper, rethrow caller cancellation, and coerce ExceptionFactory results to ApiExceptionBase.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Skymly
Skymly merged commit 0030f36 into main Aug 20, 2026
28 checks passed
@Skymly
Skymly deleted the fix/restapi-response-ownership branch August 20, 2026 11:50
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.

[Bug]: RestAPI IApiResponse disposes the HTTP response before the caller owns it

1 participant