Duplicate values in an enum cause the key to be invisible. API Review fails with "breaking changes" as a result.
- Dominant language
- C#
- Stars
- 135
- Forks
- 260
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 115
Description
[This PR](https://github.com/Azure/azure-sdk-for-python/pull/18419/files) for eventgrid added backwards compatible keys to the SystemEventNames enum. [Reference these duplicate **values**, not keys](https://github.com/Azure/azure-sdk-for-python/pull/18419/files#r630647145).
However, python an efficiency hack built in to the `Enum` class. Specifically, when a key with a _duplicate value_ is seen, it is simply aliased to the first key with that value. It is **not** actually visible in a `inspect()` or other debugging methodology.
For instance, the `SystemEventNames` enum in [eventgrid](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_event_mappings.py) has the following values (extracted for brevity)
```
...
AcsChatParticipantAddedToThreadEventName = 'Microsoft.Communication.ChatThreadParticipantAdded'
...
# backwards compat
AcsChatThreadParticipantAddedEventName = 'Microsoft.Communication.ChatThreadParticipantAdded'
...
```
The newer key name is _first_ in the enum. However, if you were to inspect this object at runtime, you would _not_ see the second key name as a member of the object. However, if you were access it specifically via
```
from azure.eventgrid import SystemEventNames
print(SystemEventNames.AcsChatThreadParticipantAddedEventName)
```
You'd actually get a value! This is because these duplicated values are merely `aliased`. NOT actually part of the object tree. The API Review tool should probably handle this edge case.
[Discussion on Stack Overflow](https://stackoverflow.com/questions/31537316/python-enums-with-duplicate-values)
Contributor guide
Assessment
This issue has not been assessed yet.