Project

Profile

Help

Issue #981

closed

API searches using critera fail with 500 instead of 400 (bad request) for invalid mongo queries

Added by jortel@redhat.com over 9 years ago. Updated over 5 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
3. High
Version:
Platform Release:
2.8.0
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Quarter:

Description

The API searches using critera fail with 500 for invalid mongo queries. This should fail with 400 (bad request).

For example, using an invalid operator in the query.

$ curl -i -H "Accept: application/json" -H "WebFrameworkSwitch: django" -X POST -k -u admin:admin  "https://localhost/pulp/api/v2/repositoriesearch/" -d '{"criteria":{"filters":{"repo_id":{"$eq":"jeff"}}}}'
HTTP/1.1 500 INTERNAL SERVER ERROR
Date: Wed, 13 May 2015 15:18:22 GMT
Server: Apache/2.4.10 (Fedora) OpenSSL/1.0.1k-fips mod_wsgi/4.3.2 Python/2.7.8
Content-Encoding: utf-8
Content-Length: 2277
Connection: close
Content-Type: application/json

{"http_request_method": "POST", "exception": ["OperationFailure: database error: invalid operator: $eq\n"], "error_message": "database error: invalid operator: $eq", "_href": "/pulp/api/v2/repositories/search/", "http_status": 500, "traceback": ["  File \"/usr/lib/python2.7/site-packages/django/core/handlers/base.py\", line 112, in get_response\n    response = wrapped_callback(request, *callback_args, **callback_kwargs)\n", "  File \"/usr/lib/python2.7/site-packages/django/views/generic/base.py\", line 69, in view\n    return self.dispatch(request, *args, **kwargs)\n", "  File \"/usr/lib/python2.7/site-packages/django/views/generic/base.py\", line 87, in dispatch\n    return handler(request, *args, **kwargs)\n", "  File \"/home/jortel/git/pulp/server/pulp/server/webservices/views/decorators.py\", line 237, in _auth_decorator\n    return _verify_auth(self, operation, super_user_only, method, *args, **kwargs)\n", "  File \"/home/jortel/git/pulp/server/pulp/server/webservices/views/decorators.py\", line 191, in _verify_auth\n    value = method(self, *args, **kwargs)\n", "  File \"/home/jortel/git/pulp/server/pulp/server/webservices/views/util.py\", line 110, in wrapper\n    return func(*args, **kwargs)\n", "  File \"/home/jortel/git/pulp/server/pulp/server/webservices/views/search.py\", line 109, in post\n    return self._generate_response(query, options, *args, **kwargs)\n", "  File \"/home/jortel/git/pulp/server/pulp/server/webservices/views/search.py\", line 140, in _generate_response\n    return cls.response_builder(cls.get_results(query, search_method, options, *args, **kwargs))\n", "  File \"/home/jortel/git/pulp/server/pulp/server/webservices/views/repositories.py\", line 313, in get_results\n    results = list(search_method(query))\n", "  File \"/usr/lib64/python2.7/site-packages/pymongo/cursor.py\", line 814, in next\n    if len(self.__data) or self._refresh():\n", "  File \"/usr/lib64/python2.7/site-packages/pymongo/cursor.py\", line 763, in _refresh\n    self.__uuid_subtype))\n", "  File \"/usr/lib64/python2.7/site-packages/pymongo/cursor.py\", line 720, in __send_message\n    self.__uuid_subtype)\n", "  File \"/usr/lib64/python2.7/site-packages/pymongo/helpers.py\", line 100, in _unpack_response\n    error_object[\"$err\"])\n"]}
Actions #1

Updated by bmbouter over 9 years ago

@jortel What version of Pulp is this?

The search stuff was re-worked in 2.7.0 so we should try to reproduce this there. It does appear this is using that new stuff, but we should confirm.

Actions #2

Updated by jortel@redhat.com over 9 years ago

bmbouter wrote:

@jortel What version of Pulp is this?

The search stuff was re-worked in 2.7.0 so we should try to reproduce this there. It does appear this is using that new stuff, but we should confirm.

The version is 2.7.0.

Actions #3

Updated by jortel@redhat.com over 9 years ago

  • Severity changed from 2. Medium to 3. High
  • Triaged changed from No to Yes
Actions #4

Updated by amacdona@redhat.com almost 9 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to amacdona@redhat.com
  • Platform Release set to 2.7.0

Added by Austin Macdonald almost 9 years ago

Revision a37b7ecb | View on GitHub

wrap the use of criteria to catch invalid criteria objects

closes: #981

Added by Austin Macdonald almost 9 years ago

Revision a37b7ecb | View on GitHub

wrap the use of criteria to catch invalid criteria objects

closes: #981

Actions #5

Updated by amacdona@redhat.com almost 9 years ago

  • Status changed from ASSIGNED to POST
Actions #6

Updated by amacdona@redhat.com almost 9 years ago

  • Status changed from POST to MODIFIED
Actions #7

Updated by amacdona@redhat.com almost 9 years ago

  • Status changed from MODIFIED to 5
Actions #8

Updated by amacdona@redhat.com almost 9 years ago

  • Status changed from 5 to MODIFIED
  • Platform Release changed from 2.7.0 to 2.7.1
Actions #9

Updated by amacdona@redhat.com almost 9 years ago

  • Platform Release changed from 2.7.1 to 2.7.2
Actions #10

Updated by dkliban@redhat.com over 8 years ago

  • Status changed from MODIFIED to 5
Actions #11

Updated by semyers over 8 years ago

  • Status changed from 5 to CLOSED - CURRENTRELEASE
  • Platform Release changed from 2.7.2 to 2.8.0
Actions #12

Updated by bmbouter over 5 years ago

  • Tags Pulp 2 added

Also available in: Atom PDF