Failing in the prefinish hook does not notify the client for error?
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?
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.
This will be implemented in the v2 release: #672