Skip to content
This repository has been archived by the owner on Mar 7, 2021. It is now read-only.

Use of Boolean "AND" in params value raises 'BadRequest' exception #9

Open
erewok opened this issue Aug 7, 2014 · 1 comment
Open
Labels

Comments

@erewok
Copy link
Contributor

erewok commented Aug 7, 2014

The following should be a valid query param as a per PMP docs:

cl.query('urn:collectiondoc:query:docs', params={'tag': 'npr_api,APM'})
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "~/.virtualenvs/someproject/lib/python3.3/site-packages/py3-pmp-wrapper/pmp_api/pmp_client.py", line 124, in query
    return self.get(self.document.query(rel_type, params=params))
  File "~/.virtualenvs/someproject/lib/python3.3/site-packages/py3-pmp-wrapper/pmp_api/pmp_client.py", line 113, in get
    results = self.connector.get(endpoint)
  File "~/.virtualenvs/someproject/lib/python3.3/site-packages/py3-pmp-wrapper/pmp_api/core/conn.py", line 92, in get
    raise BadRequest(errmsg)
pmp_api.core.exceptions.BadRequest

However, it raises a BadRequest. Does it not receive a valid response? Is the status-code bad? If so, it shouldn't be listed as BadRequest, but there should be some alternate response.

Params with a semicolon pass validation, but those with a comma do not. Please address this issue so boolean values are respected in parameters or error message provides more information as to what went wrong.

@erewok
Copy link
Contributor Author

erewok commented Aug 7, 2014

Upon further testing, the following queries all raise BadRequest:

>>> cl.query('urn:collectiondoc:query:docs', params={'tag': 'npr_api,APM'})
...
>>> cl.query('urn:collectiondoc:query:docs', params={'text': 'cove,APM'})
...

But the following works:

>>> cl.query('urn:collectiondoc:query:docs', params={'text': 'cove,test'})
<Navigable Doc: https://api-pilot.pmp.io/docs?text=cove%2Ctest>

So this is an issue with returning something useful to the user when the server does not return a proper response. Possibly inspect for JSON, look at errors field, return server's response to the user? Or raise Exception with lots of info because user is expecting JSON in response.

@erewok erewok added the bug label Aug 29, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant