Order of WireMockContainerBuilder WithX calls caused duplicate Networks in Configuration #650

Closed
opened 2025-12-29 15:29:42 +01:00 by adam · 8 comments
Owner

Originally created by @epDugas on GitHub (Dec 11, 2024).

Originally assigned to: @StefH on GitHub.

Describe the bug

The order of the .WithX calls to WireMockContainerBuilder can cause duplicate Networks in Configuration.

Expected behavior:

Expected the order of WireMockContainerBuilder.WithX calls to not duplicate Networks in the Configuration.

Test to reproduce

  • 1 Call WireMockContainerBuilder.WithNetwork(x);
  • 2 Call WireMockContainerBuilder.WithMappings(x) and WireMockContainerBuilder.WithWatchStaticMappings(true);
  • 3 Observe the configuration has two Networks, when only one was added.

This was observed when updating WireMock.net. Some previous working code failed, an exception was thrown because of the duplicate Network entries in:
https://github.com/testcontainers/testcontainers-dotnet/blob/develop/src/Testcontainers/Clients/ContainerConfigurationConverter.cs at line 30.

Networks = new ToNetworks(configuration).Convert(configuration.Networks)?.ToDictionary(item => item.Key, item => item.Value);

Changing the order of the .WithX calls resolved the issue.
image

Originally created by @epDugas on GitHub (Dec 11, 2024). Originally assigned to: @StefH on GitHub. ### Describe the bug The order of the .WithX calls to WireMockContainerBuilder can cause duplicate Networks in Configuration. ### Expected behavior: Expected the order of WireMockContainerBuilder.WithX calls to not duplicate Networks in the Configuration. ### Test to reproduce - 1 Call `WireMockContainerBuilder.WithNetwork(x);` - 2 Call `WireMockContainerBuilder.WithMappings(x)` and `WireMockContainerBuilder.WithWatchStaticMappings(true);` - 3 Observe the configuration has two Networks, when only one was added. ### Other related info This was observed when updating WireMock.net. Some previous working code failed, an exception was thrown because of the duplicate Network entries in: https://github.com/testcontainers/testcontainers-dotnet/blob/develop/src/Testcontainers/Clients/ContainerConfigurationConverter.cs at line 30. ```csharp Networks = new ToNetworks(configuration).Convert(configuration.Networks)?.ToDictionary(item => item.Key, item => item.Value); ``` Changing the order of the .WithX calls resolved the issue. ![image](https://github.com/user-attachments/assets/e8f914d4-b410-4601-8540-d08f8b65c34e)
adam added the bug label 2025-12-29 15:29:42 +01:00
adam closed this issue 2025-12-29 15:29:42 +01:00
Author
Owner

@StefH commented on GitHub (Dec 17, 2024):

@epDugas
Can you please provide a full working example (console app or unit test) which shows this issue?

@StefH commented on GitHub (Dec 17, 2024): @epDugas Can you please provide a full working example (console app or unit test) which shows this issue?
Author
Owner

@epDugas commented on GitHub (Dec 21, 2024):

See attached for console app demonstrating issue.
dotnet_console_test.zip

@epDugas commented on GitHub (Dec 21, 2024): See attached for console app demonstrating issue. [dotnet_console_test.zip](https://github.com/user-attachments/files/18217305/dotnet_console_test.zip)
Author
Owner

@StefH commented on GitHub (Dec 21, 2024):

See attached for console app demonstrating issue. dotnet_console_test.zip

Are you using Linux or Windows containers?

@StefH commented on GitHub (Dec 21, 2024): > See attached for console app demonstrating issue. [dotnet_console_test.zip](https://github.com/user-attachments/files/18217305/dotnet_console_test.zip) Are you using Linux or Windows containers?
Author
Owner

@StefH commented on GitHub (Dec 21, 2024):

@epDugas
Thanks for creating this issue. Some more entries where duplicated it seems.

It should be fixed now, can you use preview version 1.6.10-ci-19504
(https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)

@StefH commented on GitHub (Dec 21, 2024): @epDugas Thanks for creating this issue. Some more entries where duplicated it seems. It should be fixed now, can you use preview version 1.6.10-ci-19504 (https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)
Author
Owner

@epDugas commented on GitHub (Dec 21, 2024):

Thanks @StefH !

Are you using Linux or Windows containers?

Linux

@epDugas commented on GitHub (Dec 21, 2024): Thanks @StefH ! > Are you using Linux or Windows containers? Linux
Author
Owner

@StefH commented on GitHub (Dec 22, 2024):

https://github.com/WireMock-Net/WireMock.Net/pull/1222

@StefH commented on GitHub (Dec 22, 2024): https://github.com/WireMock-Net/WireMock.Net/pull/1222
Author
Owner

@StefH commented on GitHub (Dec 24, 2024):

@epDugas
If you have time, you can test version 1.6.10-ci-19519.

@StefH commented on GitHub (Dec 24, 2024): @epDugas If you have time, you can test version `1.6.10-ci-19519`.
Author
Owner

@epDugas commented on GitHub (Dec 31, 2024):

@epDugas If you have time, you can test version 1.6.10-ci-19519.

Verified issue resolved. Thanks @StefH !

@epDugas commented on GitHub (Dec 31, 2024): > @epDugas If you have time, you can test version `1.6.10-ci-19519`. Verified issue resolved. Thanks @StefH !
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#650