-
Notifications
You must be signed in to change notification settings - Fork 68
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
Image::Convert()
shows error in frontend instead of returning null
#656
Comments
Image::Convert()
shows error in frontend insteaf of failing silentlyImage::Convert()
shows error in frontend instead of failing silently
Couple of questions:
|
(Apart from that, the comment for
, but |
How do you get into that situation?
What's the reason for the failure? Is it some intermittent problem, or is it a misconfiguration, or something else?
That's actually a good argument. Looking back at the PR: #595 (comment) The
Is the error logger somehow causing an error to be thrown? Will using the default logger still log to all places that the error logger logs to? |
You tell me. ;) I have some older sites that have been upgraded a few times over time. It just happens, I guess.
The reason doesn't matter. The converter throws a Maybe there should be two different exceptions to be thrown for intermittent and permanent errors?
right. that would make sense and would be in line with all other manipulations.
The default logger logs to the log file. the error logger halts execution and AFAIK there is no way to redirect it to just a log file. I don't understand why there are two loggers anyway. |
Image::Convert()
shows error in frontend instead of failing silentlyImage::Convert()
shows error in frontend instead of returning null
I don't understand what is wrong with the submitted pull request. Not throwing an exception, and returning null, sounds like a sensible solution I get these errors when a user uploads a file with a long name within upload limits - the resampled filename, however, is too long for the filesystem
In my opinion, that's not a developer problem. It's a content issue and front-end users bear that impact. Silently logging and returning nothing should be the way to go. Developers can still be alerted and fix the problem when there's time and budget to do so. In this case, developers can simply tell the content author to rename their file and try again. |
The problem with the submitted pull request is there's no explanation of why the logger that's currently being used is incorrect. It feels like there's an underlying problem with that logger which is being ignored. If that logger should not be used directly, then documentation needs to be updated to explicitly mention that (and give the reason why), and we need to check if we're incorrectly using it anywhere else - not just this one location. |
I am experiencing this too. I think there is another serious context, in which this error is triggered: the combination of shortcode parsing and image conversion in a custom DBFile_Image.ss as described here. The conversion in DBFile_Image.ss works well, when we use an image in a template and do a conversion, e.g. In the shortcode parser this is not the case, e.g. you have Page::Content that contains a shortcode to an existing image record with a missing file. Without checking if the file exists and a conversion can occur, the conversion fails hard instead of just omitting the image. Reproduction steps:
Expected result: missing image Actual result: server error This can be mitigated by testing if the file exists in the DBFile_Image.ss template, e.g.
I find this hack ugly because it is not consistent with the way we handle resizing of corrupt Images and I'd like to avoid it if we had a better solution. |
The problem with using that logger is that it results in a hard server error, instead of omitting the image. The issue with the different loggers as well as any documentation issues are not part of the submitted pull request. If there are such issues, the submitted pull request is not meant to - and shouldn't - address those.
Do you want me to submit a pull request to return null then and not log the error at all? |
Right... but is it supposed to? If it isn't supposed to, that's an underlying bug which should be addressed directly rather than worked around.. If it is supposed to, then as I mentioned any fix should include checking if this logger is used incorrectly anywhere in the codebase and updating all such misuse, as well as documenting that. |
The error must be logged, so no. |
I don't know and that's not part of this issue/PR. |
I agree. And to make the Whether you want to create a new issue to check if the blocking error logger should be removed/documented etc, is up to you. |
I disagree. This issue points out a symptom. The bug may be wider than this one symptom. If that's the case, the wider bug should be identified and fixed, rather than treating a single symptom.
If I'm able to find some time to investigate this further personally, I will do so. In the meantime, if someone else wants to submit a PR that fixes it they'll first need to do some investigation to identify whether this is a symptom of a wider bug or not. |
The issue at hand is that the The only other locations in core where Whether or not there is a wider bug/issue in the setup of the logging system, and whether or not a hard error should show a nice error page or a blue screen, really isn't part of this issue/PR! |
Yes. That is a symptom of what looks like a wider bug. I understand you want this specific symptom fixed. The correct way to do that is to fix the wider bug (or show there isn't one but I think there is). I'm going to step away from this issue for now, since we're retreading the same points over and over again. |
I've been able to wrest some time to look into this. It seems like the current situation is:
tl;dr it's not made clear in the documentation what the difference and purposes are for the two logger services, or when to register handlers for one or the other. It is likely many developers have set up a handler for one of these services but not the other. I think an appropriate course of action is:
It would probably be sensible to add a new phpstan rule to https://github.com/silverstripe/silverstripe-standards to avoid logging to the @xini @silverstripe/core-team Does this seem sensible? |
In the meantime, in CMS 5.3 to resolve many of the cases where this is causing a problem, it would be sensible if |
@GuySartorelli yes
@GuySartorelli exactly. |
I’ve skim read the silverstripe/silverstripe-framework#8241 (PR) and silverstripe/silverstripe-framework#8044 (issue) which introduced the separate loggers for some extra context. I had a very long comment written out which after re-reading I’ve essentially boiled down to “I agree” 😝 so I’ve deleted all that and just have the following notes.
There are only a few mentions of I suspect the docs are probably from before the
As an aside to this, the suffix of |
From memory, the idea with .errorhandler was that it is not a log, rather, it let us use PSR-3 interfaces to build our error handling system. That is, use LoggerInterface for something that isn't strictly logging. It sounds like this is poorly documented. I don't think using it outside the core implementation was really given much consideration. I agree that any non-fatal information going to errorhandler is probably a mistake and/or should be ignored — it's pretty common for log handlers to have a minimum error level below which they drop messages, and errorhandler's shoulld be error. So either:
The latter would raise the misconfiguration issue, without risking the loss of error messages (they'd just show up as warnings with a prefix rather than info)
I would check whether this is actually needed. Instead, manipulating errorhandler should be done only when people want to alter what is send in the HTTP response in the event of an error - either the dev mode response with some details, or the terse "there has been an error" response in production |
I'm sorry, but I don't quite follow. The mix of errorhandler and logger is really confusing. I can log something with different 'urgency' to the logger, like
The log then gets directed to a target/handler that is set to drop <warning messages:
and I can configure a different handler for e.g. <error messages:
This logging doesn't influence application flow. The return value of a function determines the flow of the application, not the logger or log target. If I want to log an error and show the user an error page, fine. But I can also log an error/warning/info and just continue and do whatever.
(And also - again - this discussion should be held in silverstripe/silverstripe-framework#11511, not here. The issue here is simply that the wrong logger is used and |
Module version(s) affected
2.3.0
Description
When the conversion of an image fails, the error logger shows the error output on the page.
I think the conversion should fail silently and just log the error, not show it on the page.
How to reproduce
add
to the first line of
InterventionImageFileConverter::convert()
Possible Solution
use default logger instead of error logger in https://github.com/silverstripe/silverstripe-assets/blob/2/src/ImageManipulation.php#L728
instead of
Additional Context
No response
Validations
silverstripe/installer
(with any code examples you've provided)The text was updated successfully, but these errors were encountered: