protocolbuffers / protocolbuffers/protobuf

Dotnet - Include key name when failing to add to a MapField due to a duplicate key

Open Beginner friendly
#17,085 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
C++
Stars
72k
Forks
16.3k
Avg merge
1d 17h
Merged PRs (30d)
140

Description

What language does this apply to?
C#/dotnet

Describe the problem you are trying to solve.
Trying to understand why adding a key to a MapField fails

Describe the solution you'd like
The Argument exception should contain the name of the key that failed being added
https://github.com/protocolbuffers/protobuf/blob/54d8f03974c108ef8fd0f26568cd9eb086165568/csharp/src/Google.Protobuf/Collections/MapField.cs#L97

Describe alternatives you've considered
None

Additional context
We aren't using this library directly, but through a 3rd party library that uses Google.Cloud.Logging.V2, making debugging challenging

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in csharp/src/Google.Protobuf/Collections/MapField.cs at the linked failure location and inspect how duplicate keys are reported. Reproduce an attempted duplicate-key addition and update the exception behavior so the failing key name is included; done means the exception identifies that key.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend-api-design
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.