Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime "MissingRefError", with a specific kind of schema, from 4.2.0 onwards #4390

Closed
2 tasks done
Danny2462 opened this issue Oct 31, 2022 · 3 comments · Fixed by fastify/fast-json-stringify#556
Closed
2 tasks done

Comments

@Danny2462
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.2.0

Plugin version

No response

Node.js version

16.3.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

Windows 11 22H2

Description

A schema definition that uses both typebox's Type.Union() and Type.Ref() causes requests to fail with MissingRefError: "can't resolve reference (...) from id (...)"

Only a combination of Type.Union() and Type.Ref() seems to cause this, just either without the other works properly.
Doesn't seem to simply be broken references as the error would suggest.

I've had such API endpoints work fine before 4.2.0 (with 4.0.3, tested to work with 4.1.0), started failing at runtime after bumping to 4.9.2, and I found nothing in the changelog that would point to a breaking change around this.

As this feels like a simple use case, I looked over existing issues, but found nothing, the closest seems to be #4028 which was apparently resolved.

Minimal repro is linked below, with detailed guide in the readme.

If I'm screwing up / misusing something, please point me in the right direction, I'm fresh out of ideas what the mechanism could be behind this!

Steps to Reproduce

https://github.com/Danny2462/fastify-ref-error-after-4.2.0

Expected Behavior

Endpoints with schemas that worked before 4.2.0 would continue to work after a minor version bump too

@Danny2462
Copy link
Author

Also would like to grab this chance to say that, otherwise, the TypeScript support is stellar, it's such a comfortable change of pace coming from Express, cheers!

@climba03003
Copy link
Member

@ivan-tymoshenko Do you have time to take a look on this issue?

@ivan-tymoshenko
Copy link
Member

@Danny2462 I found the bug. There is an issue in the fast-json-stringify that has a failed test for your case. Unfortunately, it might take time for me to fix it.

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 a pull request may close this issue.

3 participants