pacifica / pacifica-metadata

Pacifica core service that stores the metadata for the system
GNU Lesser General Public License v3.0
1 stars 8 forks source link

[Bug] ValueError: invalid literal for int() with base 10: '%88888%' #239

Closed GitBytes closed 5 years ago

GitBytes commented 5 years ago

Pacifica Metadata version

pacifica-metadata 0.10.3 peewee 3.9.5 CherryPy 17.4.1 celery 4.2.1

Scenario:

Trying to filter the ProjectUser table results via the metadata webadmin tool and coming across this issue in the pacifica-metadata orm.

Steps to Reproduce:

Have metadata webadmin tool up and running and filter on user_id across >=29000 ProjectUser entries.

Expected Result:

filter results to very select number of results quickly

Actual Result:

Site hangs, and we receive a Traceback in metadata service logs when asking for subset of project_user table with metadata editor webtool:

Traceback (most recent call last):
  File "/opt/pacifica/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 630, in respond
    self._do_respond(path_info)
  File "/opt/pacifica/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 689, in _do_respond
    response.body = self.handler()
  File "/opt/pacifica/lib/python2.7/site-packages/cherrypy/lib/encoding.py", line 221, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/opt/pacifica/lib/python2.7/site-packages/cherrypy/lib/jsontools.py", line 58, in json_handler
    value = cherrypy.serving.request._json_inner_handler(*args, **kwargs)
  File "/opt/pacifica/lib/python2.7/site-packages/cherrypy/_cpdispatch.py", line 54, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/opt/pacifica/lib/python2.7/site-packages/pacifica/metadata/orm/base.py", line 36, in func_wrapper
    ret = func(*args, **kwargs)
  File "/opt/pacifica/lib/python2.7/site-packages/pacifica/metadata/rest/objectinfo.py", line 63, in GET
    js_object = myclass.get_object_info(where_clause)
  File "/opt/pacifica/lib/python2.7/site-packages/pacifica/metadata/orm/base.py", line 318, in get_object_info
    'record_count': cls.select().where(cls.where_clause(where_clause)).count()
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 1785, in inner
    return method(self, database, *args, **kwargs)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 2061, in count
    return Select([clone], [fn.COUNT(SQL('1'))]).scalar(database)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 1785, in inner
    return method(self, database, *args, **kwargs)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 2046, in scalar
    row = self.tuples().peek(database)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 1785, in inner
    return method(self, database, *args, **kwargs)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 2033, in peek
    rows = self.execute(database)[:n]
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 1785, in inner
    return method(self, database, *args, **kwargs)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 1856, in execute
    return self._execute(database)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 2027, in _execute
    cursor = database.execute(self)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 2952, in execute
    sql, params = ctx.sql(query).query()
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 601, in sql
    return obj.__sql__(self)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 2263, in __sql__
    ctx.literal(' FROM ').sql(CommaNodeList(self._from_list))
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 601, in sql
    return obj.__sql__(self)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 1651, in __sql__
    ctx.sql(self.nodes[n_nodes - 1])
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 601, in sql
    return obj.__sql__(self)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 2266, in __sql__
    ctx.literal(' WHERE ').sql(self._where)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 601, in sql
    return obj.__sql__(self)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 1399, in __sql__
    .sql(self.rhs))
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 601, in sql
    return obj.__sql__(self)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 1399, in __sql__
    .sql(self.rhs))
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 605, in sql
    return self.sql(Value(obj))
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 601, in sql
    return obj.__sql__(self)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 1308, in __sql__
    return ctx.value(self.value, self.converter)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 619, in value
    value = self.state.converter(value)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 4863, in db_value
    return self.rel_field.db_value(value)
  File "/opt/pacifica/lib/python2.7/site-packages/peewee.py", line 4260, in db_value
    return value if value is None else self.adapt(value)
ValueError: invalid literal for int() with base 10: '%88888%'
dmlb2000 commented 5 years ago

I'm going to call this one a duplicate of #87. The query parameter wasn't valid and we need to perform proper type checking of the query parameters.

dmlb2000 commented 5 years ago

@GitBytes might want to submit a bug to https://github.com/pacifica/pacifica-metadata-mgmt to use proper query parameters.