tus / tusd

Reference server implementation in Go of tus: the open protocol for resumable file uploads
https://tus.github.io/tusd
MIT License
3.08k stars 479 forks source link

s3store upload error: hide error from user #1175

Open webspec2012 opened 2 months ago

webspec2012 commented 2 months ago

Question

We use the s3 upload directly. We catch errors on some uploads, an example of the log is below. We haven't figured out the reason yet, but first of all we want to hide from the user how detailed the error description is. How can this be done? I haven't found a solution yet.

` {"time":"2024-08-22T13:19:59.697853753Z","level":"INFO","msg":"ResponseOutgoing","method":"POST","path":"","requestId":"f6227fd5e948b924578c3403125c9104","id":"QeUe99-_FVSY/3406cddaa43b+2~EEgYszRm2E6LiEqfb-LLIiPfIPLiqN7","status":500,"body":"ERR_INTERNAL_SERVER_ERROR: Multiple errors occurred:\n\toperation error S3: UploadPartCopy, https response error StatusCode: 404, RequestID: tx00000b777520c977ce67d-0066c73aff-1c7c0-dt-rt1, HostID: 1c7c0-dt-rt1-rt, api error NoSuchKey: UnknownError\n\toperation error S3: UploadPartCopy, https response error StatusCode: 404, RequestID: tx00000c8514efd82efebbd-0066c73aff-19c78-dt-rt1, HostID: 19c78-dt-rt1-rt, api error NoSuchKey: UnknownError\n\toperation error S3: UploadPartCopy, https response error StatusCode: 404, RequestID: tx00000d0c54e26d009f2e8-0066c73aff-1c3b8-dt-rt1, HostID: 1c3b8-dt-rt1-rt, api error NoSuchKey: UnknownError\n\toperation error S3: UploadPartCopy, https response error StatusCode: 404, RequestID: tx0000006d47737b26c2532-0066c73aff-1c7c0-dt-rt1, HostID: 1c7c0-dt-rt1-rt, api error NoSuchKey: UnknownError\n\toperation error S3: UploadPartCopy, https response error StatusCode: 404, RequestID: tx00000e2d81c2028e03c11-0066c73aff-1c304-dt-rt1, HostID: 1c304-dt-rt1-rt, api error NoSuchKey: UnknownError\n\n"}

{"time":"2024-08-22T13:19:59.697686104Z","level":"ERROR","msg":"InternalServerError","method":"POST","path":"","requestId":"f6227fd5e948b924578c3403125c9104","id":"QeUe99-_FVSY/3406cddaa43b+2~EEgYszRm2E6LiEqfb-LLIiPfIPLiqN7","message":"Multiple errors occurred:\n\toperation error S3: UploadPartCopy, https response error StatusCode: 404, RequestID: tx00000b777520c977ce67d-0066c73aff-1c7c0-dt-rt1, HostID: 1c7c0-dt-rt1-rt, api error NoSuchKey: UnknownError\n\toperation error S3: UploadPartCopy, https response error StatusCode: 404, RequestID: tx00000c8514efd82efebbd-0066c73aff-19c78-dt-rt1, HostID: 19c78-dt-rt1-rt, api error NoSuchKey: UnknownError\n\toperation error S3: UploadPartCopy, https response error StatusCode: 404, RequestID: tx00000d0c54e26d009f2e8-0066c73aff-1c3b8-dt-rt1, HostID: 1c3b8-dt-rt1-rt, api error NoSuchKey: UnknownError\n\toperation error S3: UploadPartCopy, https response error StatusCode: 404, RequestID: tx0000006d47737b26c2532-0066c73aff-1c7c0-dt-rt1, HostID: 1c7c0-dt-rt1-rt, api error NoSuchKey: UnknownError\n\toperation error S3: UploadPartCopy, https response error StatusCode: 404, RequestID: tx00000e2d81c2028e03c11-0066c73aff-1c304-dt-rt1, HostID: 1c304-dt-rt1-rt, api error NoSuchKey: UnknownError\n"} `

Acconut commented 2 months ago

Currently, there is no feature to hide such errors. But I agree, it would be useful to have this. Let me know if you are interested in helping implement it.

webspec2012 commented 2 months ago

yes, I would really like to have such functionality.

Acconut commented 2 months ago

All that is needed is an option to send a generic error message when an internal server error occurs at

https://github.com/tus/tusd/blob/1330658e881b360c394f2d76d530466193470a54/pkg/handler/unrouted_handler.go#L1177-L1178

So err.Error() should be replaced with a generic message, but only when a certain option/flag is enabled.