macfreek opened a new pull request #1522:
URL: https://github.com/apache/libcloud/pull/1522


   ## Bug fix: raise proper exception when using incorrect credentials for 
AuroraDNS
   
   ### Description
   
   This is a minor fix for a bug that was introduced in january 2016. See #1521 
for details.
   
   #### Code to reproduce:
   
   ```
   #!/usr/bin/env python3
   
   from libcloud.dns.types import Provider
   from libcloud.dns.providers import get_driver
   
   api_key = '123456'
   secret_key = 'this_is_the_wrong_password'
   
   cls = get_driver(Provider.AURORADNS)
   driver = cls(api_key, secret_key)
   
   for zone in driver.iterate_zones():
       print(zone)
   ```
   
   #### Expected exception:
   
   This should have raised an `ProviderError: Authorization failed`
   
   #### Actual exception:
   
   `TypeError: __init__() got an unexpected keyword argument 'http_status'`
   
   ### Source of the bug:
   
   This bug was introduced in commit de7862f, which includes the following 
rewrite:
   
   ```
   -            raise ProviderError(value='Authorization failed', 
http_code=status,
   -                                driver=self)
   +            error['value'] = 'Authorization failed'
   +            error['http_status'] = status
   +            raise ProviderError(**error)
   ```
   
   While the intention is clear, the author inadvertently changed the way 
`ProviderError` was called from `ProviderError(value=..., http_code=status)` to 
`ProviderError(value=..., http_status=status)`
   
   This PR fixes this bug by changing the line `error['http_status'] = status` 
to `error['http_code'] = status`
   
   ### Status
   
   - done, ready for review
   
   ### Checklist (tick everything that applies)
   
   - [X] [Code 
linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide)
 (required, can be done after the PR checks)
   - [X] Documentation
   - [ ] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html)
   - [ ] 
[ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes)
 (required for bigger changes)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to