If the database fails to insert values due to them
containing Unicode that the database can't support (or other
similar errors that fall under DBDataError), return an
HTTP 400 Bad Request rather than HTTP 500.
The following fix in oslo.db is needed for this to be
most useful, but is not a requirement:
https://review.openstack.org/#/c/265921/
This will need to be applied to numerous calls other
than just volume_create, as well.
Closes-Bug: #
1393871
Partial-Bug: #
1531400
Change-Id: I8f71df58082adca95c30d69eab211529025a3ab6
volume_ref.update(values)
session = get_session()
- with session.begin():
- session.add(volume_ref)
+ try:
+ with session.begin():
+ session.add(volume_ref)
+ except db_exc.DBDataError:
+ raise exception.Invalid()
return _volume_get(context, values['id'], session=session)