Skip to content

Conversation

@mariam-abdulla
Copy link
Member

@mariam-abdulla mariam-abdulla commented Jan 5, 2026

This pull request improves the robustness of the TerminalTestReporter class by adding safe dictionary access for test progress state lookups. Instead of directly accessing the _assemblies dictionary, the code now uses TryGetValue to prevent potential exceptions when an execution ID is missing. This ensures smoother error handling and avoids crashes in edge cases.

Error handling and robustness improvements:

  • Replaced direct dictionary access with TryGetValue in methods such as TestCompleted, TestDiscovered, and TestInProgress to gracefully handle missing execution IDs and prevent exceptions. [1] [2] [3]
  • Updated AssemblyRunCompleted to handle cases where the execution ID does not exist by reporting non-zero exit codes to the terminal and skipping state updates, improving stability for non-"TestHost" scenarios.

@mariam-abdulla mariam-abdulla requested a review from a team as a code owner January 5, 2026 09:55
Copilot AI review requested due to automatic review settings January 5, 2026 09:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves error handling in the TerminalTestReporter class by replacing direct dictionary access with TryGetValue calls to prevent KeyNotFoundException exceptions when an executionId is not found in the _assemblies dictionary.

Key changes:

  • Replaced four instances of direct dictionary access (_assemblies[executionId]) with safe TryGetValue calls
  • Added graceful handling for missing executionIds with early returns
  • Special handling in AssemblyRunCompleted to still report non-zero exit codes even when the executionId is not found

@nohwnd
Copy link
Member

nohwnd commented Jan 5, 2026

Which issue are we fixing here? It feels like this change will ignore more unexpected errors. Is it possible to rather solve the pre-condition that makes this fail?

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.

3 participants