Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Send message in batch to multiple outputs using ModuleClient throws #3434

Closed
wischi-chr opened this issue Feb 23, 2024 · 2 comments
Labels
bug Something isn't working. fix-checked-in Fix checked into main or preview, but not yet released.

Comments

@wischi-chr
Copy link

wischi-chr commented Feb 23, 2024

Context

Context is very likely irrelevant

  • OS: Windows 10 Desktop x64
  • Application's .NET Target Framework : .net core 6
  • Device: Laptop
  • SDK version used: 1.42.2 (but also inspected the source of the latest main commit)

Description of the issue

The bug is almost exactly the same as described in #3201, but for me it happened with SendEventBatchAsync.

Sending a message to multiple outputs, or multiple times throws the following exception:
An item with the same key has already been added. Key: iothub-outputname

Looking at the source it seems that the fix (using the indexer to set the property) for #3201 was only applied to the SendEventAsync method. The method SendEventBatchAsync still uses .Add() and throws.

messagesList.ForEach(m => m.SystemProperties.Add(MessageSystemPropertyNames.OutputName, outputName));

Would be great to fix it there too, I'm currently using reflection to remove the key before I call the ModuleClient - which is obviously not very pretty :-/

Thanks in advance

@timtay-microsoft
Copy link
Member

#3441 should fix this for you

timtay-microsoft added a commit that referenced this issue Mar 13, 2024
…et (#3441)

#3434

The method ```Add``` on a dictionary throws if the key is already present. This change will overwrite any previously set output name without throwing.
@timtay-microsoft timtay-microsoft added the fix-checked-in Fix checked into main or preview, but not yet released. label Mar 15, 2024
@wischi-chr
Copy link
Author

Was shipped with 1.42.3 (release notes here) so I'm closing the issue.

Thanks for fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. fix-checked-in Fix checked into main or preview, but not yet released.
Projects
None yet
Development

No branches or pull requests

2 participants