← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1471966] [NEW] Invalid json types cause stacktrace

 

Public bug reported:

Incorrect json input cause error instead of being invalidated properly:

Type error in dns_nameservers raise keyerror:

ERROR neutron.api.v2.resource [req-be58f6e1-db2f-4b2e-9620-afb49bdd4552 demo d1da3f8632e3413b915eda78899806d7] create failed
Traceback (most recent call last):
  File "/opt/stack/neutron/neutron/api/v2/resource.py", line 87, in resource
    result = method(request=request, **args)
  File "/opt/stack/neutron/neutron/api/v2/base.py", line 379, in create
    allow_bulk=self._allow_bulk)
  File "/opt/stack/neutron/neutron/api/v2/base.py", line 637, in prepare_request_body
    attr_vals['validate'][rule])
  File "/opt/stack/neutron/neutron/api/v2/attributes.py", line 275, in _validate_nameservers
    msg = _validate_ip_or_hostname(host)
  File "/opt/stack/neutron/neutron/api/v2/attributes.py", line 257, in _validate_ip_or_hostname
    name_err = _validate_hostname(host)
  File "/opt/stack/neutron/neutron/api/v2/attributes.py", line 370, in _validate_hostname
    trimmed = data if data[-1] != '.' else data[:-1]
TRACE neutron.api.v2.resource KeyError: -1
TRACE neutron.api.v2.resource·
INFO neutron.wsgi [req-be58f6e1-db2f-4b2e-9620-afb49bdd4552 demo d1da3f8632e3413b915eda78899806d7] 10.43.97.9 - - [05/Jul/2015 11:28:35] "POST //v2.0/subnets.json HTTP/1.1" 500 359 0.029233


Steps to reproduce:
token=$(keystone token-get | grep ' id ' | awk '{ print $4}')
curl -H "X-Auth-Token:${token}"  -H 'Content-Type:application/json' -X POST http://localhost:9696//v2.0/subnets.json \
 -d '{"subnet": {"dns_nameservers": [{}], "cidr": "192.168.0.1/24", "network_id": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "ip_version": "4"}}'; echo


Various sql errors with security-group params:

Trace:
ERROR neutron.api.v2.resource [req-0f32e171-029c-465a-872e-d3533fc191c7 demo 4a2f46b3469240589af5db1ffd3e56e7] create failed
TRACE neutron.api.v2.resource Traceback (most recent call last):
TRACE neutron.api.v2.resource   File "/opt/stack/neutron/neutron/api/v2/resource.py", line 87, in resource
TRACE neutron.api.v2.resource     result = method(request=request, **args)
TRACE neutron.api.v2.resource   File "/opt/stack/neutron/neutron/api/v2/base.py", line 448, in create
TRACE neutron.api.v2.resource     obj = obj_creator(request.context, **kwargs)
TRACE neutron.api.v2.resource   File "/opt/stack/neutron/neutron/db/securitygroups_db.py", line 137, in create_security_group
TRACE neutron.api.v2.resource     context.session.add(egress_rule)
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 447, in __exit__
TRACE neutron.api.v2.resource     self.rollback()
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 58, in __exit__
TRACE neutron.api.v2.resource     compat.reraise(exc_type, exc_value, exc_tb)
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 444, in __exit__
TRACE neutron.api.v2.resource     self.commit()
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 354, in commit
TRACE neutron.api.v2.resource     self._prepare_impl()
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 334, in _prepare_impl
TRACE neutron.api.v2.resource     self.session.flush()
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1818, in flush
TRACE neutron.api.v2.resource     self._flush(objects)
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1936, in _flush
TRACE neutron.api.v2.resource     transaction.rollback(_capture_exception=True)
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 58, in __exit__
TRACE neutron.api.v2.resource     compat.reraise(exc_type, exc_value, exc_tb)
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1900, in _flush
TRACE neutron.api.v2.resource     flush_context.execute()
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 372, in execute
TRACE neutron.api.v2.resource     rec.execute(self)
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 525, in execute
TRACE neutron.api.v2.resource     uow
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 64, in save_obj
TRACE neutron.api.v2.resource     table, insert)
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 541, in _emit_insert_statements
TRACE neutron.api.v2.resource     execute(statement, multiparams)
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 662, in execute
TRACE neutron.api.v2.resource     params)
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sq
TRACE neutron.api.v2.resource     compiled_sql, distilled_params
TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 874, in _execute_context
TRACE neutron.api.v2.resource     context)
TRACE neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/oslo/db/sqlalchemy/compat/handle_error.py", line 125, in _handle_dbapi_exception
TRACE neutron.api.v2.resource     six.reraise(type(newraise), newraise, sys.exc_info()[2])
TRACE neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/oslo/db/sqlalchemy/compat/handle_error.py", line 102, in _handle_dbapi_exception
TRACE neutron.api.v2.resource     per_fn = fn(ctx)
TRACE neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/oslo/db/sqlalchemy/exc_filters.py", line 323, in handler
TRACE neutron.api.v2.resource     context.is_disconnect)
TRACE neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/oslo/db/sqlalchemy/exc_filters.py", line 278, in _raise_for_remaining_DBAPIError
TRACE neutron.api.v2.resource     raise exception.DBError(error)
TRACE neutron.api.v2.resource DBError: (ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '), '')' at line 1") 'INSERT INTO securitygroups (tenant_id, id, name, description) VALUES (%s, %s, %s, %s)' ('4a2f46b3469240589af5db1ffd3e56e7', '35ba859f-475d-4afb-8c36-a4d3b434aeb9', [], '')

Steps to reproduce:
token=$(keystone token-get | grep ' id ' | awk '{ print $4}')
curl -H "X-Auth-Token:${token}"  -H 'Content-Type:application/json' -X POST http://10.43.97.9:9696//v2.0/security-groups.json   -d '{"security_group": {"name": []}}'; echo

** Affects: neutron
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1471966

Title:
  Invalid json types cause stacktrace

Status in OpenStack Neutron (virtual network service):
  New

Bug description:
  Incorrect json input cause error instead of being invalidated
  properly:

  Type error in dns_nameservers raise keyerror:

  ERROR neutron.api.v2.resource [req-be58f6e1-db2f-4b2e-9620-afb49bdd4552 demo d1da3f8632e3413b915eda78899806d7] create failed
  Traceback (most recent call last):
    File "/opt/stack/neutron/neutron/api/v2/resource.py", line 87, in resource
      result = method(request=request, **args)
    File "/opt/stack/neutron/neutron/api/v2/base.py", line 379, in create
      allow_bulk=self._allow_bulk)
    File "/opt/stack/neutron/neutron/api/v2/base.py", line 637, in prepare_request_body
      attr_vals['validate'][rule])
    File "/opt/stack/neutron/neutron/api/v2/attributes.py", line 275, in _validate_nameservers
      msg = _validate_ip_or_hostname(host)
    File "/opt/stack/neutron/neutron/api/v2/attributes.py", line 257, in _validate_ip_or_hostname
      name_err = _validate_hostname(host)
    File "/opt/stack/neutron/neutron/api/v2/attributes.py", line 370, in _validate_hostname
      trimmed = data if data[-1] != '.' else data[:-1]
  TRACE neutron.api.v2.resource KeyError: -1
  TRACE neutron.api.v2.resource·
  INFO neutron.wsgi [req-be58f6e1-db2f-4b2e-9620-afb49bdd4552 demo d1da3f8632e3413b915eda78899806d7] 10.43.97.9 - - [05/Jul/2015 11:28:35] "POST //v2.0/subnets.json HTTP/1.1" 500 359 0.029233

  
  Steps to reproduce:
  token=$(keystone token-get | grep ' id ' | awk '{ print $4}')
  curl -H "X-Auth-Token:${token}"  -H 'Content-Type:application/json' -X POST http://localhost:9696//v2.0/subnets.json \
   -d '{"subnet": {"dns_nameservers": [{}], "cidr": "192.168.0.1/24", "network_id": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "ip_version": "4"}}'; echo

  
  Various sql errors with security-group params:

  Trace:
  ERROR neutron.api.v2.resource [req-0f32e171-029c-465a-872e-d3533fc191c7 demo 4a2f46b3469240589af5db1ffd3e56e7] create failed
  TRACE neutron.api.v2.resource Traceback (most recent call last):
  TRACE neutron.api.v2.resource   File "/opt/stack/neutron/neutron/api/v2/resource.py", line 87, in resource
  TRACE neutron.api.v2.resource     result = method(request=request, **args)
  TRACE neutron.api.v2.resource   File "/opt/stack/neutron/neutron/api/v2/base.py", line 448, in create
  TRACE neutron.api.v2.resource     obj = obj_creator(request.context, **kwargs)
  TRACE neutron.api.v2.resource   File "/opt/stack/neutron/neutron/db/securitygroups_db.py", line 137, in create_security_group
  TRACE neutron.api.v2.resource     context.session.add(egress_rule)
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 447, in __exit__
  TRACE neutron.api.v2.resource     self.rollback()
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 58, in __exit__
  TRACE neutron.api.v2.resource     compat.reraise(exc_type, exc_value, exc_tb)
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 444, in __exit__
  TRACE neutron.api.v2.resource     self.commit()
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 354, in commit
  TRACE neutron.api.v2.resource     self._prepare_impl()
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 334, in _prepare_impl
  TRACE neutron.api.v2.resource     self.session.flush()
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1818, in flush
  TRACE neutron.api.v2.resource     self._flush(objects)
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1936, in _flush
  TRACE neutron.api.v2.resource     transaction.rollback(_capture_exception=True)
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 58, in __exit__
  TRACE neutron.api.v2.resource     compat.reraise(exc_type, exc_value, exc_tb)
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1900, in _flush
  TRACE neutron.api.v2.resource     flush_context.execute()
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 372, in execute
  TRACE neutron.api.v2.resource     rec.execute(self)
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 525, in execute
  TRACE neutron.api.v2.resource     uow
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 64, in save_obj
  TRACE neutron.api.v2.resource     table, insert)
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 541, in _emit_insert_statements
  TRACE neutron.api.v2.resource     execute(statement, multiparams)
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 662, in execute
  TRACE neutron.api.v2.resource     params)
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sq
  TRACE neutron.api.v2.resource     compiled_sql, distilled_params
  TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 874, in _execute_context
  TRACE neutron.api.v2.resource     context)
  TRACE neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/oslo/db/sqlalchemy/compat/handle_error.py", line 125, in _handle_dbapi_exception
  TRACE neutron.api.v2.resource     six.reraise(type(newraise), newraise, sys.exc_info()[2])
  TRACE neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/oslo/db/sqlalchemy/compat/handle_error.py", line 102, in _handle_dbapi_exception
  TRACE neutron.api.v2.resource     per_fn = fn(ctx)
  TRACE neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/oslo/db/sqlalchemy/exc_filters.py", line 323, in handler
  TRACE neutron.api.v2.resource     context.is_disconnect)
  TRACE neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/oslo/db/sqlalchemy/exc_filters.py", line 278, in _raise_for_remaining_DBAPIError
  TRACE neutron.api.v2.resource     raise exception.DBError(error)
  TRACE neutron.api.v2.resource DBError: (ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '), '')' at line 1") 'INSERT INTO securitygroups (tenant_id, id, name, description) VALUES (%s, %s, %s, %s)' ('4a2f46b3469240589af5db1ffd3e56e7', '35ba859f-475d-4afb-8c36-a4d3b434aeb9', [], '')

  Steps to reproduce:
  token=$(keystone token-get | grep ' id ' | awk '{ print $4}')
  curl -H "X-Auth-Token:${token}"  -H 'Content-Type:application/json' -X POST http://10.43.97.9:9696//v2.0/security-groups.json   -d '{"security_group": {"name": []}}'; echo

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1471966/+subscriptions


Follow ups

References