Comment 21 for bug 1062046

Revision history for this message
Gary Kotton (garyk) wrote : Re: [Bug 1062046] Re: There is a lot of cases that API with an invalid parameter returns 500.

On 10/26/2012 10:13 AM, Itsuro Oda wrote:
> This is my test pattern: (this log is under patch set 12) --- curl -v
> -H "X-Auth-Token: ee94a1f0743b4c269acb0b14c1281523" -H "Content-Type:
> application/json" -X POST -d '{{"name": "aaa"}}'
> http://172.17.190.3:9696/v2.0/networks.json * About to connect() to
> 172.17.190.3 port 9696 (#0) * Trying 172.17.190.3... connected
Would it be possible to trf and add the following and let me know if it
helps:

diff --git a/quantum/api/v2/base.py b/quantum/api/v2/base.py
index a370381..6484b8e 100644
--- a/quantum/api/v2/base.py
+++ b/quantum/api/v2/base.py
@@ -48,6 +48,7 @@ FAULT_MAP = {exceptions.NotFound: webob.exc.HTTPNotFound,
               exceptions.PolicyNotAuthorized: webob.exc.HTTPForbidden,
               netaddr.AddrFormatError: webob.exc.HTTPBadRequest,
               AttributeError: webob.exc.HTTPBadRequest,
+ ValueError: webob.exc.HTTPBadRequest,
               }

And

diff --git a/quantum/api/v2/resource.py b/quantum/api/v2/resource.py
index 8300a53..785943d 100644
--- a/quantum/api/v2/resource.py
+++ b/quantum/api/v2/resource.py
@@ -94,7 +94,7 @@ def Resource(controller, faults=None,
deserializers=None, serializers=None):
              method = getattr(controller, action)

              result = method(request=request, **args)
- except (AttributeError,
+ except (ValueError, AttributeError,
                  exceptions.QuantumException,
                  netaddr.AddrFormatError) as e:
              LOG.exception('%s failed' % action)

Thanks
Gary