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

sheepdog returns 500 status and non-descriptive error message #302

Open
jacquayj opened this issue Sep 26, 2019 · 0 comments
Open

sheepdog returns 500 status and non-descriptive error message #302

jacquayj opened this issue Sep 26, 2019 · 0 comments

Comments

@jacquayj
Copy link

When creating a project record, if a validation error occurs, a non-descriptive error message ({ "error": "service failure - try again later"}) is returned with a status of 500.

Viewing the pod logs, I get more info:

[2019-09-26 19:21:47,461][sheepdog.api][  ERROR] Value '' not in allowed value list for ['Open', 'Restricted'] for property availability_type.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/sheepdog/sheepdog/utils/__init__.py", line 123, in check
    return func(program, *args, **kwargs)
  File "/sheepdog/sheepdog/blueprint/routes/views/program/__init__.py", line 186, in create_project
    node.props.update(base_doc)
  File "/usr/lib/python2.7/site-packages/psqlgraph/attributes.py", line 57, in update
    setattr(self.source, key, val)
  File "/usr/lib/python2.7/site-packages/sqlalchemy/ext/hybrid.py", line 900, in __set__
    self.fset(instance, value)
  File "/usr/lib/python2.7/site-packages/psqlgraph/base.py", line 281, in hybrid_prop
    validate(fset, value, fset.__pg_types__, fset.__pg_enum__)
  File "/usr/lib/python2.7/site-packages/psqlgraph/util.py", line 22, in validate
    ).format(value, enum, f.__name__))

Since this is a user input error, I'd expect a 400 Bad Request response code with errors embedded in the response:

{
   "errors": {
      "availability_type": "Value '' not in allowed value list for ['Open', 'Restricted']"
   }
}

This example response is just a suggestion, but it would be nice to inform the React application of the specific field where an error occurred, so server-side error messages can be rendered on the client. This is beneficial because you don't need to implement client-side validation in addition to server-side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant