Fix Zod validation for non-string enums in OpenAPI parser#4
Merged
Conversation
ENG-9167 MCP server silently fails on OpenAPI endpoints with integer enums
The OpenAPI parser in |
mikesellitto
requested review from
amoses12,
another-yijiao,
dp-franklin and
emily-curry
February 18, 2026 21:30
emily-curry
approved these changes
Feb 18, 2026
dp-franklin
reviewed
Feb 19, 2026
| return z.union( | ||
| schema.enum.map((val: any) => z.literal(val)) as [ | ||
| z.ZodLiteral<any>, | ||
| z.ZodLiteral<any>, |
There was a problem hiding this comment.
fyi: I assume that the z.union type requires at least two items in the array, but only one item is actually required at runtime. (0 will throw)
dp-franklin
approved these changes
Feb 19, 2026
z.enum() only accepts string values, so integer enums like visType: [0, 1, 2] on change request endpoints would fail validation before the request ever reached our api, producing a generic "tool execution failed" error. Now we use z.union of z.literal values for non-string enums instead.
mikesellitto
force-pushed
the
mike/parser-enum-fix
branch
from
February 19, 2026 21:23
0c84421 to
47f3724
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, The OpenAPI parser in
src/parser.tsconverts all enum fields to z.enum(), which only supports string values. When the OpenAPI spec defines an non-string enum (i.e. visType with"type": "integer", "enum": [0, 1, 2]), the resulting Zod schema rejects every inputThis PR makes it so that we use
z.unionofz.literalvalues for non-string enums instead.Closes ENG-9167