Skip to content

Conversation

@macfreek
Copy link
Contributor

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)

  • Code linting (required, can be done after the PR checks)
  • Documentation
  • Tests
  • ICLA (required for bigger changes)

@codecov-io
Copy link

Codecov Report

Merging #1522 (5829845) into trunk (66ab3ca) will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##            trunk    #1522   +/-   ##
=======================================
  Coverage   84.77%   84.77%           
=======================================
  Files         388      388           
  Lines       81718    81718           
  Branches     8270     8270           
=======================================
  Hits        69278    69278           
  Misses       9440     9440           
  Partials     3000     3000           
Impacted Files Coverage Δ
libcloud/dns/drivers/auroradns.py 71.74% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66ab3ca...5829845. Read the comment docs.

@Kami
Copy link
Member

Kami commented Dec 6, 2020

Thanks for the contribution.

The change looks good to me. I added (regression) test case for it and merged it into trunk - d3dec97.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants