Repository navigation
Fix AzureDevOpsReport teardown crash and silent live-publishing failures by @Evangelink in #10291 (backport to rel/4.3) - #10504
Merged
Amaury Levé (Evangelink) merged 8 commits intoAug 7, 2026
Conversation
The Azure DevOps live test-results publisher is disposed twice during teardown (once when the test host disposes its services, once again during process shutdown). Its Dispose() called Cancel() on an already disposed CancellationTokenSource, which crashed the test host with an unhandled ObjectDisposedException after all tests had passed and after results had already been published. microsoft#10195 removed one duplicate-dispose path inside a single disposal pass but the crash still reproduces end to end, so make Dispose() idempotent. The follow-up symptom (no crash, but no published results) has the same root cause surface: when the Azure DevOps environment is incomplete the publisher silently disabled itself from IsEnabledAsync and only logged to the diagnostic file log, so users saw neither a test run nor a reason. Keep the extension enabled whenever --publish-azdo-test-results is set and report the missing configuration on the output device instead. Fixes microsoft#10191 Co-authored-by: Copilot App <[email protected]> Copilot-Session: b564deae-b8d2-49aa-96d3-9308ec461d89
…ures - WarnAsync no longer propagates output-device exceptions. It is called from error-recovery paths and from session teardown, where CommonTestHost does not guard lifetime handlers, so a throw would have turned a diagnostic warning into a failed run - the same class of bug this change set fixes. - Reset the publisher state before reporting the run-creation failure so a display failure can never leave it half-initialized. - Route the post-run failures through the output device too. These are the ones that produce the reported symptom: a run left in InProgress does not appear in the Tests tab, and results left in the retry queue after the session-end flush are never retried. Report dropped results once with a count rather than per failed batch, to avoid spamming a warning every flush interval. - Replace the double-dispose-without-session test, which passed with and without the fix, by one covering the inert-but-registered path that keeping the extension enabled now creates (ConsumeAsync/OnTestSessionFinishingAsync/Dispose on a misconfigured publisher). Co-authored-by: Copilot App <[email protected]> Copilot-Session: b564deae-b8d2-49aa-96d3-9308ec461d89
…ting, message accuracy
- Attachment failures were still log-only. They are swallowed per attachment so
one bad file cannot abort the drain, which made the outer catch unreachable and
the changelog claim wrong. Count them at the real failure sites (run-level,
result-level, and the batch skipped when result IDs cannot be parsed) and
report one summary at session end. Coverage files and dumps no longer go
missing without explanation.
- ConsumeAsync renewed the coordination lease before enqueuing the result, so an
I/O failure there dropped the result before it reached a queue and the
end-of-session count could not see it. Enqueue first.
- WarnAsync's fallback reused 'failed to publish test results' for a failure to
write to the output device, which in the finalize path claimed results had
failed to publish when they had all succeeded. Use a dedicated message.
- Make the missing-configuration warning provably non-null via [NotNullWhen(false)]
rather than falling back to the unformatted resource string, which would have
shown a raw '{0}' on the console.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: b564deae-b8d2-49aa-96d3-9308ec461d89
Per-attachment failures are counted inside UploadResultAttachmentsAsync, so the only non-cancellation exception the surrounding catch can see is one thrown by RenewLeaseAsync - in which case no upload is attempted and the whole attachment set was dropped without being counted, making the end-of-session summary under-report. Assert the summary from the existing result-attachment failure test so the common counting path is covered. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b564deae-b8d2-49aa-96d3-9308ec461d89
WarnAsync documents a never-throws contract but called _logger.LogWarning outside any guard. Logger invokes each registered provider directly, so a failing provider propagated out of the helper - including out of its own catch block, where it replaced the exception being handled. Route both logging attempts through TryLogWarning so a broken diagnostic logger can neither suppress the output-device attempt nor escape the recovery path. Run finalization excluded OperationCanceledException from its catch, but it runs on its own cleanupCts rather than the session token, so an expiry there (or an HttpClient TaskCanceledException) escaped this lifetime handler and could fail an otherwise successful run - exactly the teardown crash this change set exists to prevent. Treat it like the other finalization failures. Both regressions are covered by tests that fail when the fix is reverted. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b564deae-b8d2-49aa-96d3-9308ec461d89
OnTestSessionFinishingAsync is a lifetime handler and the platform does not guard those, so a throwing log provider in its recovery catches escaped and failed an otherwise successful run - the same defect already fixed inside WarnAsync, one frame away. Route the background-flush and session-end flush catches through TryLogWarning, plus the matching ConsumeAsync catch so the recovery paths are consistent. Covered by a test that drives a publish failure and then breaks the log provider before teardown; it fails when the guard is reverted. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b564deae-b8d2-49aa-96d3-9308ec461d89
The test only asserted that one line reached the output device, so a mutation emitting an arbitrary string or the wrong resource key would have survived. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b564deae-b8d2-49aa-96d3-9308ec461d89
A throwing log provider escaping these catches did more than fail the run: it aborted the attachment drain so the rest of the queue was never attempted and never counted, and when it escaped the per-attachment catch the caller treated it as a pre-upload lease failure and added the whole attachment set again, double-counting failures and mis-reporting successful uploads as failed. Route every recovery-path log in the publisher through TryLogWarning so the loops continue and the end-of-session counts stay accurate. The invariant is now checkable: the only direct _logger.LogWarning call left is the one inside TryLogWarning itself. Covered by a test that fails two run attachments with a broken log provider and asserts both are attempted and counted; it fails when the guard is reverted. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b564deae-b8d2-49aa-96d3-9308ec461d89
Amaury Levé (Evangelink)
enabled auto-merge (squash)
August 7, 2026 10:39
Amaury Levé (Evangelink)
approved these changes
Aug 7, 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.
Backport of #10291 to rel/4.3
/cc Amaury Levé (@Evangelink)