Repository navigation
[repo-assist] test: cover CallAsync readBody exception fallback - #496
Merged
sergey-tihon merged 1 commit intoSep 19, 2026
Merged
sergey-tihon merged 1 commit into
sergey-tihon merged 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Test-only change with complete fallback-path coverage and no unresolved review issues.
Review effort: Lite
Findings: None
What changed in this PR
Adds regression coverage for CallAsync when response-body decoding fails, confirming fallback to an empty body.
Changes:
- Added an invalid-charset HTTP handler.
- Added assertions for
OpenApiExceptionstatus, body, and message.
| File | Description |
|---|---|
tests/SwaggerProvider.Tests/RuntimeHelpersTests.fs |
Adds handler and fallback-path test coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
sergey-tihon
deleted the
repo-assist/test-callasync-readbody-fallback-49bdf2d03c78160c
branch
September 19, 2026 05:46
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
ProvidedApiClientBase.CallAsync(insrc/SwaggerProvider.Runtime/ProvidedApiClientBase.fs) has areadBodyhelper with a try/with fallback:This fallback branch (reading the error response body fails, so
OpenApiExceptionis still raised with an empty body) had no test coverage — all existingCallAsynctests exercised only the success path ofreadBody.Change
Added
SwaggerProvider.Tests.RuntimeHelpersTests.OpenApiExceptionTests.``CallAsync falls back to empty body when reading response content throws```. A new stub handler (InvalidCharsetHandler) returns an error response whoseContent-Typedeclares a bogus charset.HttpClient's internal response buffering only copies raw bytes (charset-agnostic), so the request succeeds up toCallAsync, but the explicitReadAsStringAsync()call insidereadBodyfails while decoding with the invalid charset — exercising the catch-all branch and confirmingOpenApiException.ResponseBodyis""` while the documented error description is still used.No production code was changed; this is a test-only addition.
Test Status
dotnet build SwaggerProvider.sln -c Release: succeeded (pre-existing warnings only, no errors).dotnet tests/SwaggerProvider.Tests/bin/Release/net10.0/SwaggerProvider.Tests.dll: 574/574 passed (573 → 574; 1 skipped, unrelated to this change).dotnet fantomas --check tests/SwaggerProvider.Tests/RuntimeHelpersTests.fs: passed, no formatting issues.Add this agentic workflow to your repo
To install this agentic workflow, run