Skip to content

fix: EnumTransformer.to_literal accepts a string matching an enum value#3439

Open
1fanwang wants to merge 1 commit into
flyteorg:masterfrom
1fanwang:enum-to-literal-accepts-string
Open

fix: EnumTransformer.to_literal accepts a string matching an enum value#3439
1fanwang wants to merge 1 commit into
flyteorg:masterfrom
1fanwang:enum-to-literal-accepts-string

Conversation

@1fanwang

@1fanwang 1fanwang commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Why are the changes needed?

EnumTransformer.assert_type accepts a raw string that matches one of the enum's values (for instance an enum default supplied as a string), but EnumTransformer.to_literal rejects that same string with Expected an enum. So a matching-string value passes type-checking and then fails at serialization.

What changes were proposed in this pull request?

to_literal now accepts a string matching one of the enum's values and serializes it to the corresponding literal, consistent with assert_type. A non-matching string is still rejected.

How was this patch tested?

Added test_enum_to_literal_accepts_matching_string — it fails on the current code with TypeTransformerFailedError: Expected an enum and passes with the fix.

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

@1fanwang 1fanwang force-pushed the enum-to-literal-accepts-string branch from f995050 to 11c9eaf Compare June 19, 2026 18: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