ERROR handleCallbackRequest Failed to register callback result

I've integrated UploadThing in my platform. The client is a NextJS application and the server is a cluster of NestJS microservices. The issue is that after a successful file upload (on UploadThing the file is present), the onUploadComplete callback is not executed, thus not finishing the upload correctly on the client, because I'm getting:
00:40:26.611 DEBUG handleCallbackRequest 'onUploadComplete' callback finished. Sending response to UploadThing:
ᐉ { "callbackData": {"fileKey":"Yp1sykmpbCf4flJwaXR7axB1jFwdyoRIVZnUlCELh5Xtc9Mm","callbackData":"https://utfs.io/f/Yp1sykmpbCf4flJwaXR7axB1jFwdyoRIVZnUlCELh5Xtc9Mm"} }
00:40:26.620 INFO handleUploadAction -> handleJsonLineStream Successfully simulated 'callback' event
00:40:26.819 ERROR handleCallbackRequest Failed to register callback result (400)
ᐉ { "error": {"error":"Invalid request body","details":[{"code":"invalid_type","expected":"object","received":"string","path":["callbackData"],"message":"Expected object, received string"}]} }
00:40:26.820 DEBUG handleCallbackRequest ResponseError: StatusCode: non 2xx status code (400 POST https://sea1.ingest.uploadthing.com/callback-result)
00:40:26.611 DEBUG handleCallbackRequest 'onUploadComplete' callback finished. Sending response to UploadThing:
ᐉ { "callbackData": {"fileKey":"Yp1sykmpbCf4flJwaXR7axB1jFwdyoRIVZnUlCELh5Xtc9Mm","callbackData":"https://utfs.io/f/Yp1sykmpbCf4flJwaXR7axB1jFwdyoRIVZnUlCELh5Xtc9Mm"} }
00:40:26.620 INFO handleUploadAction -> handleJsonLineStream Successfully simulated 'callback' event
00:40:26.819 ERROR handleCallbackRequest Failed to register callback result (400)
ᐉ { "error": {"error":"Invalid request body","details":[{"code":"invalid_type","expected":"object","received":"string","path":["callbackData"],"message":"Expected object, received string"}]} }
00:40:26.820 DEBUG handleCallbackRequest ResponseError: StatusCode: non 2xx status code (400 POST https://sea1.ingest.uploadthing.com/callback-result)
Since I'm developing, I've made sure to have the isDev flag to true. Implementing UploadThing has been almost effortless and I really like it, but there's this error that I can't understand, maybe I'm dumb and forgot something... PLS help, I'm cooked.
Solution:
hey - that error you're getting is probably cause you're returning a string from onUploadComplete. We expect the return to be an object. I've submitted a patch that will type-error when returning primitive values so this will become a compile-time error instead of a surfacing first at runtime https://github.com/pingdotgg/uploadthing/pull/968
Jump to solution
3 Replies
markr
markr2mo ago
Hmm can you share your uploadthing file router config?
Solution
julius
julius2mo ago
hey - that error you're getting is probably cause you're returning a string from onUploadComplete. We expect the return to be an object. I've submitted a patch that will type-error when returning primitive values so this will become a compile-time error instead of a surfacing first at runtime https://github.com/pingdotgg/uploadthing/pull/968
Christian Carpinelli
Thanks Julius, I don't know why I haven't thought of it, but yes a patch is needed:blessjmg: Regardless, congratulations on building such a cool product, I look forward to show you guys how I used it!
Want results from more Discord servers?
Add your server