You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
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!
@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.
Prerequisites
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()
andType.Ref()
causes requests to fail withMissingRefError
:"can't resolve reference (...) from id (...)"
Only a combination of
Type.Union()
andType.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
The text was updated successfully, but these errors were encountered: