tusd icon indicating copy to clipboard operation
tusd copied to clipboard

Failing in the prefinish hook does not notify the client for error?

Open TaridaGeorge opened this issue 4 years ago • 1 comments

I want to know what is the expected behavior when an error is thrown from the pre-finish hook.
Should the error propagate to the client or not?

I was thinking that if I throw an error from the pre-finish hook this error will propagate to the client, but this doesn't seems to be the current behavior. In the tusd server I can see this:

[tusd] event="HookInvocationFinish" type="post-receive" id="a15..." 
[tusd] event="ResponseOutgoing" status="500" method="PATCH" path="a15..." error="pre-finish hook failed: rpc error: code = Internal desc = Unable to handle the uploaded file!
[tusd] event="HookInvocationError" type="pre-finish" id="a15..." error="rpc error: code = Internal desc = Unable to handle the uploaded file!

but the client success callback handler is called.

Is this the expected behavior?

TaridaGeorge avatar Jul 30 '21 16:07 TaridaGeorge

Yes, this is currently the expect behavior. The error response from tusd to the client contains the error message that you set in the gRPC endpoint: pre-finish hook failed: rpc error: code = Internal desc = Unable to handle the uploaded file!

In the future we hope to make the error response caused by hooks more customizable (i.e. set a custom response code and body), but this is not yet implemented at the time of writing.

Acconut avatar Aug 02 '21 12:08 Acconut

This will be implemented in the v2 release: #672

Acconut avatar Aug 23 '23 11:08 Acconut