Skip to content

Conversation

@zengande
Copy link
Contributor

@zengande zengande commented Aug 6, 2025

When generating the dropdown list for the status input in the WriteHttpResponse activity, duplicate enum values were included due to Enum.GetValues() returning multiple names with the same underlying numeric value from System.Net.HttpStatusCode.

This fix filters the list to include only distinct values, grouped by their underlying integer representation.

Related issue: #6845


This change is Reviewable

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 StaticDropDownOptionsProvider to deduplicate enum values by grouping on their integer representation and selecting the first name for each unique value.

Comment on lines +42 to +44
var enumValues = Enum.GetValues(wrappedPropertyType)
.Cast<Enum>()
.GroupBy(Convert.ToInt32)
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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))

Copilot uses AI. Check for mistakes.
@sfmskywalker sfmskywalker force-pushed the main branch 2 times, most recently from 4e58970 to ae1bb77 Compare December 10, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant