Skip to content
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

Handled error to return the reason of failure as part of the response. #1013

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mms/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ def predict(self, batch):
except MemoryError:
logger.error("System out of memory", exc_info=True)
return create_predict_response(None, req_id_map, "Out of resources", 507)
except Exception: # pylint: disable=broad-except
except Exception as e: # pylint: disable=broad-except
logger.warning("Invoking custom service failed.", exc_info=True)
return create_predict_response(None, req_id_map, "Prediction failed", 503)
return create_predict_response(None, req_id_map, "Prediction failed : [{}]".format(e), 503)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is bad practice to return exception details to client for unknown generic exceptions, as it can expose sensitive implementation details.

It would be fine to log the original exception though when wrapping in generic message.

Even without patch, the model code can use mms.PredictionException to preserve error code and message (see line 109 just a few lines above this)


if not isinstance(ret, list):
logger.warning("model: %s, Invalid return type: %s.", self.context.model_name, type(ret))
Expand Down