-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
TBD: Don't throw 404 in /core/preview.png?file= if no preview exists #24216
Comments
It makes sense to return 404s here though, since the client asked for a resource and it was not found? Perhaps you need to tweak your OSSEC rules to exclude that path? |
Yes, sure. The rule is already tweaked:
However the question is, if the client is asking for a resource or oC is pointing the client to a non-existent resource? |
Similar topic: #17557 |
Previews for unsupported file types just shouldn't be requested in the first place. Most nice and future-proof way to do so would be to export "previewable" (supported by backend) filetypes into frontend context at runtime and then request preview only for matching (so supported) files. Admin setting would also be great In other words, only supported files should have
and all others should use statics like
|
I don't see any problems to return some placeholder image from server if preview can't be generated. Why not? |
At least 'coz this would be masking/working around the issue, not actually fixing it. Also this would probably break file-type dependent fallback icons until you reimplement them at the server side by returning different placeholders based on file type. Which would be sort of code duplication.
Nothing complex there really |
It's a question of what fix is the TRUE one :). Sometimes there is no single TRUE solution.
I'm not very acknowledged with OC. If it's true then you're right, we can't use placeholder images.
Between placeholders instead of 404 and determining "previewable" on server-side, getting "previewable" filetypes, determining if this file is previewable on client side? Of course the 2nd option is complex. |
I think we can make more simple solution. We get an xml list of files with some properties on navigation using request to |
And I'm in no way claimimng that my is the only one) I just telling that making requests for non-previewable types is meaningless runtime work, so that route is [probably] suboptimal and so not true. "Probably" is because I'm too not really familiar with OC code, my suggestion is based on assumption that there must be some sort of ThumbBuilder programmatic entity which by definition knows what is previewable and what is not, and that that knowlegde may be "exported" in declarative form (so no runtime checks for each file). If runtime checks would be required for each file, things wouldn't be so obvious anymore, but I'm "pretty sure" "declarative export" should be possible
This is actually one of possible implementations of what I'm talking about) |
Even when disabling previews altogether (in config.php) the clients continue to be served 404s. That's pointless. This one should definitely be fixed. |
Logically, the current behaviour makes sense. The client asks the server for a preview of a file, the server reports there isn't one. A 404 isn't necessarily an error condition. The problem is that we don't allow the client to cache the 404s, which is bad for performance. |
No it doesn't. As per RFC7231:
So there should be by definition an error condition. |
Properly behaving servers SHOULD NOT throw 4xx around, and fill the logs, and overburden monitoring systems, and screw up IPS/IDS, etc. |
when i change the apps/files/js/filelist.js file like this,,looks very well,,but the unit test error diff -r ./apps/files/js/filelist.js /var/www/core/build/dist/owncloud/apps/files/js/filelist.js |
@milancoin-project Thanks for taking up this one. |
Can you elaborate on this ? How would the exception be handled and what would be the actual response of "preview.png" then ? The problem is that the server needs a way to tell the JS side that there was no actual preview for the requested file so it can fallback to displaying an icon. The current approach is returning 404. If we'd return 200, then it would believe that there is an actual preview and no icon would be shown. I think the correct approach is to have the server provide a list of mime types for which we know there will be a preview. That list could be provided as part of "OC.MimeTypeList" (generated file) in a new "supportedPreviews" section. |
@PVince81 Sorry for the poor language. What I mean is that OC uses the mechanism of one component issuing an instruction to another component that results in the other component throwing an error, that is caught lazily by the first component. In this case, the user browser (upon instruction of the server) asks for an non existing file, and the server passes an error back. In the case of #23213 the php server tries to insert an existing unique key in the database, which passes an error back. All these errors get however logged, which makes proper monitoring less efficient. It seems to me that this is not what error mechanisms are meant for: they should signal an error happening, whereas here they are part of intended behaviour. |
What about "204 - No Content"? JS knows what to do without errors in the logfile... In my opinion a better response. |
@DeepDiver1975 @PVince81 could we come to a conclusion here? I have gotten complaints about this behaviour from other places as well. |
This requirement cannot be fulfilled, especially with APIs like Webdav. That said, for the previews I guess what bothers people is mostly that these 404 appear too often instead of being rare cases. The quickest solution then is probably to return a 204 - No content or something similar and have the JS code check against that and fallback to mime type icons. @VicDeo can you take care of this ? |
Exactly. Especially as the client / browser got pointed by ownCloud to a non-existing resource which is then throwing that 404. Its not the opposite that the browser just accessing the non-existing resource on its own. |
Just another IMHO: for webservers that I maintain I always exclude static assets locations from error log. :) |
But i don't see where this should apply here. Just see the /core/preview.png?file=/foo URL provided by ownCloud as a dead link on your web page: You're better off in fixing the dead link pointing to the 404 than hiding the errors from the logfiles. |
Back in OC 13. Seems like we have a regression here. |
Sorry, I meant NC. Wrong repo. Closed again. |
Steps to reproduce
The rule can be easily updated to not jump in if 404s are happening on /core/preview.png but still it might be better to not throw that much 404s.
Expected behaviour
https://demo.owncloud.org/core/preview.png?file=/foo should return a placeholder preview
Actual behaviour
https://demo.owncloud.org/core/preview.png?file=/foo is returning a 404 causing a HIDS to jump in
Server configuration
ownCloud version: 9.0.1
The text was updated successfully, but these errors were encountered: