api-platform-tools icon indicating copy to clipboard operation
api-platform-tools copied to clipboard

listedeployments produces stack trace

Open codebudo opened this issue 11 years ago • 4 comments

$ apigeetool listdeployments -o codebudo -e test -u codebudo -p (redacted)
Traceback (most recent call last):
  File "/usr/local/bin/apigeetool", line 26, in <module>
    listdeployments.run()
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ApigeePlatformTools/listdeployments.py", line 63, in run
    deploytools.getAndPrintEnvDeployments(Organization, Environment)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ApigeePlatformTools/deploytools.py", line 108, in getAndPrintEnvDeployments
    printDeployments(getAndParseEnvDeployments(org, env))
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ApigeePlatformTools/deploytools.py", line 105, in getAndParseEnvDeployments
    return parseEnvDeployments(org, response, env)   
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ApigeePlatformTools/deploytools.py", line 41, in parseEnvDeployments
    deployments = json.load(resp)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 290, in load
    **kw)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

The values of the -o, -u and -p don't seem to matter. I get this same stack trace no matter what values I choose. I'm entering what I believe to be my correct credentials, but I can't be sure with this tool. Is there a verbose or debug option?

codebudo avatar Feb 19 '14 18:02 codebudo

Thanks for checking this out. Sadly we need to improve the error messages.

One way that you can tell what is going wrong would be to run the following command in curl, which is basically the equivalent:

curl -u codebudo:PASSWORD https://api.enterprise.apigee.com/v1/o/codebudo/e/test/deployments

This will tell us if the problem is something like an incorrect password or if it's something else (and then what we should fix).

On Wed, Feb 19, 2014 at 10:10 AM, Sebastian Mikkel Wilson < [email protected]> wrote:

$ apigeetool listdeployments -o codebudo -e test -u codebudo -p (redacted) Traceback (most recent call last): File "/usr/local/bin/apigeetool", line 26, in listdeployments.run() File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ApigeePlatformTools/listdeployments.py", line 63, in run deploytools.getAndPrintEnvDeployments(Organization, Environment) File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ApigeePlatformTools/deploytools.py", line 108, in getAndPrintEnvDeployments printDeployments(getAndParseEnvDeployments(org, env)) File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ApigeePlatformTools/deploytools.py", line 105, in getAndParseEnvDeployments return parseEnvDeployments(org, response, env) File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ApigeePlatformTools/deploytools.py", line 41, in parseEnvDeployments deployments = json.load(resp) File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/init.py", line 290, in load **kw) File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/init.py", line 338, in loads return _default_decoder.decode(s) File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 365, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 383, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded

The values of the -o, -u and -p don't seem to matter. I get this same stack trace no matter what values I choose. I'm entering what I believe to be my correct credentials, but I can't be sure with this tool. Is there a verbose or debug option?

Reply to this email directly or view it on GitHubhttps://github.com/apigee/api-platform-tools/issues/3 .

greg brail | apigee https://apigee.com/ | twitter @gbrailhttp://twitter.com/gbrail

gbrail avatar Feb 19 '14 18:02 gbrail

Hey, thanks for the quick response! :+1: curl -v -u codebudo:PASSWORD https://api.enterprise.apigee.com/v1/o/codebudo/e/test/deployments reveals

< HTTP/1.1 401 Unauthorized
< Date: Wed, 19 Feb 2014 18:37:59 GMT
< Server: Jetty(8.0.4.v20111024)
* Authentication problem. Ignoring this.

However, using my email address instead of username does produce a response. Similarly, I get a response to the apigeetool listdeployments call when using my email instead of my username.

These would be my recommendations:

  1. The tool should not display the stack trace
  2. Display an error message when it receives an error response
  3. The documentation says to use -u Apigee user name where it should read -u Apigee email address.
  4. (optional) Ditch the concept of a username globally. It does more harm than good. :-)

codebudo avatar Feb 19 '14 18:02 codebudo

I'm not much of a Pythonista, but I've put some try: except blocks in place that produce slightly more helpful error messages. I've pushed these two commits to a branch on my fork f3656df43808b3445ce35df67d1956b52fcde4e0 and dd9a5d629ce2a1fbdcbd69c0ecbbfd2388710e60 . Can someone with more Python experience tell me if this is the right way to do this?

codebudo avatar Feb 28 '14 19:02 codebudo

Yes, I think that you're on the right track. I think that a start is just to catch and print the exceptions like you're doing rather than print the stack trace which is not helpful of course. We also may have to check the specific error for different exceptions as well, and I'm not sure how to do that off the top of my head without some more doc reading...

But if you could print out a nice exception when the user enters the wrong password, that would go a very long way!

On Fri, Feb 28, 2014 at 11:03 AM, Sebastian Mikkel Wilson < [email protected]> wrote:

I'm not much of a Pythonista, but I've put some try: except blocks in place that produce slightly more helpful error messages. I've pushed these two commits to a branch on my fork f3656dfhttps://github.com/apigee/api-platform-tools/commit/f3656df43808b3445ce35df67d1956b52fcde4e0and dd9a5d6https://github.com/apigee/api-platform-tools/commit/dd9a5d629ce2a1fbdcbd69c0ecbbfd2388710e60. Can someone with more Python experience tell me if this is the right way to do this?

Reply to this email directly or view it on GitHubhttps://github.com/apigee/api-platform-tools/issues/3#issuecomment-36383201 .

greg brail | apigee https://apigee.com/ | twitter @gbrailhttp://twitter.com/gbrail

gbrail avatar Mar 01 '14 00:03 gbrail