Repository navigation
Stop the output schema recursing on a self-referential record - #26
Merged
Merged
Conversation
A record type that contains itself is normal: a tweet quotes a tweet, a comment has replies, a directory entry has children. schemaForType walked straight into it and the process died with a stack overflow the first time anything asked for the schema, which is every serve startup and every MCP tools/list. The walk now carries the structs open above it and describes the second occurrence as a plain object. The path is the set that matters, not every type ever seen: two sibling fields of the same type are not a cycle and both still expand.
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.
schemaForTypeexpanded a struct field of its own type forever. Any domain with a self-referential record (a tweet that quotes a tweet, a comment with replies) took a stack overflow the moment something asked for the output schema, which isserveon startup andmcpon tools/list.The walk now carries the set of structs open above it and answers the second occurrence with a plain object. The path is what matters rather than every type seen, so two sibling fields of the same type still both expand; there is a test for each.
Found while filling in x-cli's serve and mcp surfaces (tamnd/x-cli#18).