Fix: Remove duplicate enum values in HttpStatusCode dropdown for WriteHttpResponse#6846
Fix: Remove duplicate enum values in HttpStatusCode dropdown for WriteHttpResponse#6846zengande wants to merge 1 commit intoelsa-workflows:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where the WriteHttpResponse activity's status code dropdown displayed duplicate entries. The issue arose because System.Net.HttpStatusCode contains multiple enum names with the same underlying integer values (e.g., HttpStatusCode.Ambiguous and HttpStatusCode.MultipleChoices both equal 300).
Key Changes:
- Modified
StaticDropDownOptionsProviderto deduplicate enum values by grouping on their integer representation and selecting the first name for each unique value.
| var enumValues = Enum.GetValues(wrappedPropertyType) | ||
| .Cast<Enum>() | ||
| .GroupBy(Convert.ToInt32) |
There was a problem hiding this comment.
The deduplication logic uses Convert.ToInt32 which will fail for enums with underlying types other than int (e.g., long, byte, short). While HttpStatusCode uses int, this is a generic enum handler. Consider using Enum.GetUnderlyingType() to safely convert values regardless of the underlying type, or use GroupBy(x => x) with a custom comparer to avoid type-specific conversion altogether.
| var enumValues = Enum.GetValues(wrappedPropertyType) | |
| .Cast<Enum>() | |
| .GroupBy(Convert.ToInt32) | |
| var underlyingType = Enum.GetUnderlyingType(wrappedPropertyType); | |
| var enumValues = Enum.GetValues(wrappedPropertyType) | |
| .Cast<Enum>() | |
| .GroupBy(x => Convert.ChangeType(x, underlyingType)) |
4e58970 to
ae1bb77
Compare
When generating the dropdown list for the
statusinput in theWriteHttpResponseactivity, duplicate enum values were included due toEnum.GetValues()returning multiple names with the same underlying numeric value fromSystem.Net.HttpStatusCode.This fix filters the list to include only distinct values, grouped by their underlying integer representation.
Related issue: #6845
This change is