Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 8, 2025

Description

Fixes #12101

Two tests were switching from resource "app1" to resource "app2" but only updating the Resource parameter, leaving ResourceByName containing the old resource. This created an inconsistent state that could trigger dictionary key collisions in internal component tracking, manifesting as "An item with the same key has already been added" errors.

Changed:

  • ClickMaskAllSwitch_NewResource_MaskChanged: Now updates ResourceByName when switching to resource2
  • ClickMaskEnvVarSwitch_NewResource_MaskChanged: Now updates ResourceByName when switching to resource2

Both tests now maintain parameter consistency by including the new resource in ResourceByName:

cut.SetParametersAndRender(builder =>
{
    builder.Add(p => p.Resource, resource2);
    builder.Add(p => p.ResourceByName, new ConcurrentDictionary<string, ResourceViewModel>([new KeyValuePair<string, ResourceViewModel> (resource2.Name, resource2)]));
});

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
Original prompt

This section details on the original issue you should resolve

<issue_title>Failing test: Aspire.Dashboard.Components.Tests.Controls.ResourceDetailsTests.ClickMaskAllSwitch_NewResource_MaskChanged</issue_title>
<issue_description>## Build Information
Build: https://github.com/dotnet/aspire/actions/runs/19119212010
Build error leg or test failing: Aspire.Dashboard.Components.Tests.Controls.ResourceDetailsTests.ClickMaskAllSwitch_NewResource_MaskChanged
Pull request:

Error Message

Fill the error message using step by step known issues guidance.

{
  "ErrorMessage": "",
  "ErrorPattern": "",
  "BuildRetry": false,
  "ExcludeConsoleLog": false
}

Error Details

System.ArgumentException : An item with the same key has already been added. Key: f6ecec4b
Stack Trace
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Microsoft.FluentUI.AspNetCore.Components.FluentAccordion.Register(FluentAccordionItem item)
   at Microsoft.FluentUI.AspNetCore.Components.FluentAccordionItem.OnInitialized()
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
   at Bunit.Rendering.TestRenderer.AssertNoUnhandledExceptions() in /_/src/bunit.core/Rendering/TestRenderer.cs:line 629
   at Bunit.Rendering.TestRenderer.Render[TResult](RenderFragment renderFragment, Func`2 activator) in /_/src/bunit.core/Rendering/TestRenderer.cs:line 480
   at Bunit.Rendering.TestRenderer.RenderFragment(RenderFragment renderFragment) in /_/src/bunit.core/Rendering/TestRenderer.cs:line 101
   at Bunit.Extensions.TestContextBaseRenderExtensions.RenderInsideRenderTree(TestContextBase testContext, RenderFragment renderFragment) in /_/src/bunit.core/Extensions/TestContextBaseRenderExtensions.cs:line 43
   at Bunit.Extensions.TestContextBaseRenderExtensions.RenderInsideRenderTree[TComponent](TestContextBase testContext, RenderFragment renderFragment) in /_/src/bunit.core/Extensions/TestContextBaseRenderExtensions.cs:line 23
   at Bunit.TestContext.Render[TComponent](RenderFragment renderFragment) in /_/src/bunit.web/TestContext.cs:line 68
   at Bunit.TestContext.RenderComponent[TComponent](Action`1 parameterBuilder) in /_/src/bunit.web/TestContext.cs:line 54
   at Aspire.Dashboard.Components.Tests.Controls.ResourceDetailsTests.ClickMaskAllSwitch_NewResource_MaskChanged() in /_/tests/Aspire.Dashboard.Components.Tests/Controls/ResourceDetailsTests.cs:line 118
--- End of stack trace from previous location ---

Last 10 failures:

Run date Build Type Test Name OS
nov 05 11 pm pr#12101 ClickMaskAllSwitch_NewResource_MaskChanged windows

Summary

Last 24 hrs Last 7 days Last 30 days Most Affected OS Failure Rate
0 1 (1 PRs, 0 rolling) 1 (1 PRs, 0 rolling) windows (100%) 0.0%

-- Updated on 11/7/2025 3:12:27 PM UTC

</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix failing test in ResourceDetailsTests for ClickMaskAllSwitch Fix ResourceDetailsTests flaky failures when switching resources Nov 8, 2025
Copilot AI requested a review from radical November 8, 2025 21:10
Copilot finished work on behalf of radical November 8, 2025 21:10
@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12847

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12847"

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.

Failing test: Aspire.Dashboard.Components.Tests.Controls.ResourceDetailsTests.ClickMaskAllSwitch_NewResource_MaskChanged

2 participants