[ci-fix] Needs review: Unwrap TargetInvocationException in AsyncEnumerable tests on tvOS Mono (refs #128766)#129654
Draft
github-actions[bot] wants to merge 2 commits into
Draft
Conversation
On Mono/tvOS, async iterator exceptions propagated through JsonSerializer.SerializeAsyncEnumerable are wrapped in a TargetInvocationException. The tests previously used Assert.ThrowsAsync<InvalidOperationException> which fails when the exception is wrapped. Replace with Assert.ThrowsAnyAsync<Exception> followed by explicit unwrapping of TargetInvocationException, then assert the inner exception is InvalidOperationException. This works correctly on both CoreCLR (direct exception) and Mono (wrapped exception). Remove the [ActiveIssue] annotations that disabled these tests on Apple Mobile Mono since the fix addresses the behavioral difference. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-text-json |
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.
Workflow artifact: ci-fix
Artifact kind: help
Linked KBE: #128766
Note
This is an AI/Copilot-generated draft PR that attempts to fix the CI failure described in KBE #128766. It has NOT been build-validated (environment lacks .NET 11 SDK). Human review is needed.
Root cause
On tvOS Mono, exceptions thrown during async iterator execution in
JsonSerializer.SerializeAsyncEnumerableare wrapped in aSystem.Reflection.TargetInvocationException. The tests useAssert.ThrowsAsync<InvalidOperationException>which fails when the expected exception is wrapped.Failing log line:
This is a known behavioral difference in Mono's async iterator exception propagation. The
InvalidOperationExceptionIS correctly thrown by the serializer, but Mono wraps it during the async pipeline unwinding.Fix
Replace
Assert.ThrowsAsync<InvalidOperationException>with:This correctly handles both:
InvalidOperationExceptiondirectly — assertion passesTargetInvocationExceptionwrappingInvalidOperationException— unwraps and passesRemove the
[ActiveIssue]annotations since the fix addresses the root cause.What is unverified / help needed
Suggested reviewers / area contacts
@eiriktsarpalis(area-System.Text.Json owner)@simonrozsival(Apple mobile / Mono contributor)Validation
dotnet build src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csprojEvidence
Filed by
ci-failure-fix, which attempts validated fixes for[ci-scan]Known Build Errors and otherwise loops in owners. Comment here or on the workflow file to suggest changes;ci-failure-scan-feedbackreads in-scope feedback daily and opens (or updates) a PR with prompt edits.Note
🔒 Integrity filter blocked 2 items
The following items were blocked because they don't meet the GitHub integrity level.
issue_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".issue_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter: