Skip to content
This repository has been archived by the owner on May 9, 2020. It is now read-only.

Unhelpful/Erroneous error on bad node search #78

Open
ZachtimusPrime opened this issue Sep 19, 2017 · 0 comments
Open

Unhelpful/Erroneous error on bad node search #78

ZachtimusPrime opened this issue Sep 19, 2017 · 0 comments

Comments

@ZachtimusPrime
Copy link

ZachtimusPrime commented Sep 19, 2017

My Environment:

  • Windows
  • Python 3.6.2
  • PyChef 0.3.0

Issue:
Erroneous "unauthorized" error message if the node hostname is in the wrong format.

Good Example (No erroneous space in front of hostname):

hostname = "hostname"

api = chef.ChefAPI.from_config_file("E:\\path\\to\\knife\\file")
node = chef.Node(hostname)

Good Result:
Comes back with node information if the node exists in Chef.

Bad Example (Erroneous space in front of hostname):

hostname = " hostname"

api = chef.ChefAPI.from_config_file("E:\\path\\to\\knife\\file")
node = chef.Node(hostname)

Bad Result:

Traceback (most recent call last):
  File "e:/chef/validate_host.py", line 33, in <module>
    node = chef.Node(hostname)
  File "C:\Program Files\Python36\lib\site-packages\chef\base.py", line 58, in __init__
    data = self.api[self.url]
  File "C:\Program Files\Python36\lib\site-packages\chef\api.py", line 221, in __getitem__
    return self.api_request('GET', path)
  File "C:\Program Files\Python36\lib\site-packages\chef\api.py", line 217, in api_request
    response = self.request(method, path, headers, data)
  File "C:\Program Files\Python36\lib\site-packages\chef\api.py", line 207, in request
    raise ChefServerError.from_error(response.reason, code=response.status_code)
chef.exceptions.ChefServerError: Unauthorized
@ZachtimusPrime ZachtimusPrime changed the title WINDOWS: Unhelpful/Erroneous error on bad node search Unhelpful/Erroneous error on bad node search Sep 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant