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

Unhelpful/Erroneous error on bad node search #78

Description

@ZachtimusPrime

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions