-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
S3 backend with TUS handler fails to handle PATCH #1067
Comments
To be frank, I am not able to follow your description here. We have been running tusd with S3 like this for years without issues, even though URLs regularly contain non-alphanumeric letters like
Not sure what this link should show us. It links to an implementation of the |
I used a debugger and followed the code paths. And I'm currently using Digital Oceans S3 service, so yes non "official" I have forked It's not an error message; it's the fact the router never matches the route due to non-alphanumeric characters, which is a fundamentally low-level problem. That o/c means a 404 and breaking everything. |
Can you please provide an exemplary upload URL that is returned by tusd when used with DigitalOcean Spaces? Using that, we can attempt to make the routing work. Some related work has already started in the past in #1020, but is still far from being completed. |
However, my opinion is to try and replace |
I tried to reproduce this with DigitalOcean Spaces but uploads were working. Here are the logs to show that it was able to route the URL:
The URL also looked similar to yours: http://localhost:8080/files/70a8dc8076ccf0deec0b93397068ebd7+2~Qz-9TvpBUZI7jhe4GL2DDxgQmplp0El Is there anything I am missing? That being said, there is a bug resulting in a 404 being returned when trying to GET a completed upload. |
I reverted the patches I made to test again: On a PATCH request to It partially matches the route, but when it goes to You can find my configuration/setup of TUS with this debug test at https://git.lumeweb.com/LumeWeb/portal/src/commit/9002064937ae0f869af09964c5c72694cd10f97f/storage/storage.go#L124 |
Additionally #1071 seems to be a new edge case unrelated to mine (outside being S3) 😅 |
Alright, this clear the fog. The problem is not that the URL contains non-alphanumeric characters but that in your case the path begin with a slash (`path = "/221e2a31b396eae8eeab..."). But the routes do not expect a starting slash: Line 42 in eddfff4
That's why the route does not match. If I modify tusd to manually add the beginning slash, I get the same 404 errors: I would recommend you to look into Line 53 in eddfff4
In tusd, we should probably make our logic handle these cases as well. I hope that helps for now. |
Thanks, ill prob stick to my fork for now because I prefer them all on the same router, and the changes were minor, and I fixed the routing issues that came up after. I had Sorry for the goose chase, though at-least 1 bug fix came from it. |
Alright, whatever you prefer. I am glad the situation has been cleared up. #1020 contains an improvement which makes tusd not choke on the leading slash. Feel free to try it out. |
Describe the bug
I have been digging through a lot of routing code and found the s3 backend creates a compound ID at
tusd/pkg/s3store/s3store.go
Line 339 in e278419
However,
pat
, the router, only supports alphanumeric characters with:id
Mux:
https://github.com/bmizerany/pat/blob/e4b6760bdd6f5467d6b19ff8f0f85a00938eb64a/mux.go#L236
Register:
tusd/pkg/handler/handler.go
Line 42 in e278419
I see a few fixes:
I would recommend replacing
pat
. More people, including me, are using https://github.com/julienschmidt/httprouter, which does not have the same restriction.I will have to fork this, and I can submit a PR with feedback on how the project maintainers want to proceed on this bug.
To Reproduce
Could you create an embedded TUS server with the handler and a s3 backend?
Expected behavior
It should route the PATCH request for a file properly.
Setup details
Please provide following details, if applicable to your situation:
The text was updated successfully, but these errors were encountered: