yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #23809
[Bug 1193253] Re: String attributes should limit the length in API
I just tried the reproducer on a devstack box and it seems to have been
fixed ( I get a 500 response when trying to create the network given in
the example). I poked around a bit but couldn't find where it was fixed
but the stack trace goes up all the way to oslo.db:
2014-10-16 15:50:02.743 ERROR oslo.db.sqlalchemy.exc_filters [req-32367df8-1b00-4f72-a662-51cf89ca3486 demo 55bde6e3ca3342758d347c78dbafd67c] DBAPIError exception wrapped fr
om (DataError) (1406, "Data too long for column 'name' at row 1") 'INSERT INTO networks (tenant_id, id, name, status, admin_state_up, shared) VALUES (%s, %s, %s, %s, %s, %s)
' ('55bde6e3ca3342758d347c78dbafd67c', '305f3d5e-971a-43a0-a99e-2e62a6d8f1e7', 'test12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890',
'ACTIVE', 1, 0)
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters Traceback (most recent call last):
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters File "/usr/lib/python2.7/site-packages/oslo/db/sqlalchemy/compat/handle_error.py", line 59, in _handle_dbapi_e
xception
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters e, statement, parameters, cursor, context)
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters exc_info
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/compat.py", line 196, in raise_from_cause
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters reraise(type(exception), exception, tb=exc_tb)
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 867, in _execute_context
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters context)
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 324, in do_execute
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters cursor.execute(statement, parameters)
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters File "/usr/lib64/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters self.errorhandler(self, exc, value)
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters raise errorclass, errorvalue
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters DataError: (DataError) (1406, "Data too long for column 'name' at row 1") 'INSERT INTO networks (tenant_id, id,
name, status, admin_state_up, shared) VALUES (%s, %s, %s, %s, %s, %s)' ('55bde6e3ca3342758d347c78dbafd67c', '305f3d5e-971a-43a0-a99e-2e62a6d8f1e7', 'test12345678901234567890
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123
4567890123456789012345678901234567890123456789012345678901234567890', 'ACTIVE', 1, 0)
2014-10-16 15:50:02.743 TRACE oslo.db.sqlalchemy.exc_filters
2014-10-16 15:50:02.745 ERROR neutron.api.v2.resource [req-32367df8-1b00-4f72-a662-51cf89ca3486 demo 55bde6e3ca3342758d347c78dbafd67c] create failed
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource Traceback (most recent call last):
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/api/v2/resource.py", line 87, in resource
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource result = method(request=request, **args)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/api/v2/base.py", line 448, in create
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource obj = obj_creator(request.context, **kwargs)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/plugins/ml2/plugin.py", line 492, in create_network
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource result = super(Ml2Plugin, self).create_network(context, network)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/db_base_plugin_v2.py", line 901, in create_network
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource context.session.add(network)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 447, in __exit__
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource self.rollback()
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 58, in __exit__
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource compat.reraise(exc_type, exc_value, exc_tb)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 444, in __exit__
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource self.commit()
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 354, in commit
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource self._prepare_impl()
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 334, in _prepare_impl
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource self.session.flush()
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 1828, in flush
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource self._flush(objects)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 1946, in _flush
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource transaction.rollback(_capture_exception=True)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 58, in __exit__
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource compat.reraise(exc_type, exc_value, exc_tb)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 1910, in _flush
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource flush_context.execute()
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 372, in execute
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource rec.execute(self)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 525, in execute
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource uow
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 64, in save_obj
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource table, insert)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 541, in _emit_insert_statements
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource execute(statement, multiparams)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 662, in execute
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource params)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource compiled_sql, distilled_params
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 874, in _execute_context
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource context)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/oslo/db/sqlalchemy/compat/handle_error.py", line 125, in _handle_dbapi_exception
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource six.reraise(type(newraise), newraise, sys.exc_info()[2])
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/oslo/db/sqlalchemy/compat/handle_error.py", line 102, in _handle_dbapi_exception
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource per_fn = fn(ctx)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/oslo/db/sqlalchemy/exc_filters.py", line 323, in handler
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource context.is_disconnect)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource File "/usr/lib/python2.7/site-packages/oslo/db/sqlalchemy/exc_filters.py", line 278, in _raise_for_remaining_DBAPIError
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource raise exception.DBError(error)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource DBError: (DataError) (1406, "Data too long for column 'name' at row 1") 'INSERT INTO networks (tenant_id, id, name, status, admin_state_up, shared) VALUES (%s, %s, %s, %s, %s, %s)' ('55bde6e3ca3342758d347c78dbafd67c', '305f3d5e-971a-43a0-a99e-2e62a6d8f1e7', 'test12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890', 'ACTIVE', 1, 0)
2014-10-16 15:50:02.745 TRACE neutron.api.v2.resource
** Changed in: neutron
Status: Triaged => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1193253
Title:
String attributes should limit the length in API
Status in OpenStack Neutron (virtual network service):
Fix Released
Bug description:
I use the latest code of Grizzly, and create a network. The name of network is longer then 255 characters.
Then I list networks, the name of network has only 255 characters.
This is my request:
{
"network":
{
"name": "test12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
}
}
And this is list network responce:
{
"networks": [
{
"status": "ACTIVE",
"subnets": [],
"name": "test12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901",
"provider:physical_network": "physnet1",
"admin_state_up": true,
"tenant_id": "6fbe9263116a4b68818cf1edce16bc4f",
"provider:network_type": "vlan",
"router:external": false,
"shared": false,
"id": "40a59f54-d8c0-432c-a2ef-6a8151348054",
"provider:segmentation_id": 54
}
]
}
The name lost 9 characters.
I found the code in /quantum/db/models_v2.py
class Network(model_base.BASEV2, HasId, HasTenant):
"""Represents a v2 quantum network."""
name = sa.Column(sa.String(255))
ports = orm.relationship(Port, backref='networks')
subnets = orm.relationship(Subnet, backref='networks')
status = sa.Column(sa.String(16))
admin_state_up = sa.Column(sa.Boolean)
shared = sa.Column(sa.Boolean)
It defines ths name's limit is 255 characters. But there is no
parameter check when create network.
To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1193253/+subscriptions