must be an instance of FormData (was object)
Hello!
This code:
Throws following error:
However,
formData
is instanceof FormData
and the log also says it's FormData
:
What am I doing wrong?27 Replies
What did you see that makes you sure it's an instance of
FormData
?
Try just creating it from new FormData()
instead and see if that worksI did
console.log(formData)
Did you try it with:
I need something I can actually repro
This throws the same error
Works for me
Aw :(
Well,
parse.number
works inside of this package, but now it's formData
I mean it would be one thing if it was unresolvable like before but you're saying this time that it's not an instanceof FormData but that's not the error I get
Can you just show me the error message
.toString()
like I did?You get that even if you just pass
new FormData()
directly to the validator?Yes, as per the first picture
I'm on
Node 20.14.0
Typescript 5.5.3
Arktype 2.0.0-beta.5
May as well try
beta.6
I can't repro it with those exact versionsI tried the latest version, also installed it at the root of the workspace, so that there would only be one installation of Arktype, still the same error
I tried my best to repro it you will have to link me a repo/branch I can clone
I think I found where the issue lies. When using Arktype in Vite directly, it works fine, but when I was running it through a server file, which included this code, which installs
undici
:
it must've been setting a polyfilled FormData
on globalThis
. Hence it had the same name but wasn't seen as the same object, since Arktype is in a separate package.
Me again with the formdata 😆
When running this on the client, everything works fine:
But on the server:
I get this error:
What could be the issue?Hmm not sure that doesn't make any sense. You could introspect the data a bit to see what it means by
was "profile"
, but the fact that it's only happening on the server makes me thing it's some nonsense remix is doing like it was the last time.Must be
I guess the quotes are staying there?
But shouldn't that be handled by
parse.formData
?Maybe the polyfilled formdata is wrong
Yes, the issue is definitely on the Remix side. But how come the error had the quotation marks around everything?
I don't have enough context from what you posted to understand haha
And not double quotes
I'd say though if it works on the client and there was something weird going on on the server, probably not worth digging into that much
No, I mean the wrong value that was passed was
"profile"
instead of profile
. But the error only showed one ("
) quotation marks:
intent must be "private" or "profile" (was "profile")
Hmm yeah maybe there is an issue there
Yep just added a new test case for this, thanks!
Between multiple kinds of precompilation and undiscriminated and discriminated unions there are so many places to get error messages right 🫠
I can only imagine 😁