-
Notifications
You must be signed in to change notification settings - Fork 857
Fixed unhandled "'NoneType' object has no attribute 'mode'" detector exceptions #841
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
Fixed unhandled "'NoneType' object has no attribute 'mode'" detector exceptions #841
Conversation
| try: | ||
| features = self.get_features() | ||
| except Exception: | ||
| features = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add logging here? Silencing exceptions isn't great. Also added a metric would be awesome so things can be tracked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I could. I'm just not very sure what should be logged/tracked here. The detector is trying to get features within a meta request. To be honest I'm not sure what exactly makes this error. My best guess is that something is not being initialized as a "metadata only" performance optimalization. Any additional thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least the exception message should be logged otherwise this is silently ignoring potential problems with no way of knowing something went wrong.
| ) | ||
| ) | ||
| except Exception: | ||
| self.next(callback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
|
@mvdklip is this ready to be merged? |
|
@masom Yes as far as I'm concerned. I moved on to a different client, but would be great to have this merged to the base Thumbor. |
|
Hey, @mvdklip, any hints on how to reproduce the |
|
@scorphus As mentioned in the initial comment this exception can be triggered by requesting metadata for a GIF image with USE_GIFSICLE_ENGINE enabled. A link to an example problematic image is provided, but I think it can actually be triggered by any GIF image. |
|
@mvdklip Nice. Would you be willing to write such a test? |
|
@scorphus Willing yes, but to be honest I will probably never do it. I moved on to a different client which means I'm not actively working on Thumbor anymore. Sorry. |
|
I wonder how this exception can happen in general. Do you have a config file + real request where this error happened? Because if def smart_detect(self):
is_gifsicle = (self.context.request.engine.extension == '.gif' and self.context.config.USE_GIFSICLE_ENGINE)
if (not (self.context.modules.detectors and self.context.request.smart)) or is_gifsicle:
self.do_image_operations()
returnthe only other place where I find the face_detector to be used is in the filter |
|
This URL exhibited the behaviour on both Thumbor 5.x and 6.x: /unsafe/meta/1000x1000/smart/s3-eu-west-1.amazonaws.com/nrcapp/cbf1017e5d2f798d48f5cf07bc428f0b12835e9e Also attaching config file: |
the JSONEngine was not having the `extension` attribute stored from the wrapped Engine which leads to the exception fixed (ignored) in thumbor#841 with the added extension part the transformer won't call smart detection if gifsicle is enabled and it's a GIF image
in thumbor#841 the exception were caugth and ignored and only a small warning was logged, this will not allow to debug the underlying issue (because it was actually a fixable issue, see thumbor#883).. so now the exception is logged as well
|
@mvdklip thanks! helped me to find the root cause of your exception |
Unhandled exceptions inside the face and feature detectors cause HTTP connections to hang and 'Future exception was never retrieved' tornado error messages to be logged.
Example problem image:
http://s3-eu-west-1.amazonaws.com/nrcapp/cbf1017e5d2f798d48f5cf07bc428f0b12835e9e
This PR handles the exception by going to the next detector and replaces #812 because I messed that one up.
This problem only seems to occur when USE_GIFSICLE_ENGINE = True and when using the Metadata Endpoint.