Invalid connection settings not throwing reasonable exceptions
nuwang opened this issue · 0 comments
nuwang commented
Having invalid connection settings such as a None value for subscription_id in Azure, does not throw a reasonable exception.
E.g. the error thrown is as follows
File "/Users/Nuwan/work/djcloudbridge/djcloudbridge/domain_model.py", line 50, in get_cloud_provider
config)
File "/Users/Nuwan/work/djcloudbridge/venv/lib/python3.6/site-packages/cloudbridge/cloud/factory.py", line 142, in create_provider
return provider_class(config)
File "/Users/Nuwan/work/djcloudbridge/venv/lib/python3.6/site-packages/cloudbridge/cloud/providers/azure/provider.py", line 52, in __init__
'storacc' + self.subscription_id[-6:] +
TypeError: 'NoneType' object is not subscriptable
The ideal behaviour is to accept an empty Config without errors, because sometimes, the config settings may come from a boto config for example. but for provider.authenticate() and any connection related methods to throw an appropriate error, like InvalidProviderSetting or similar. If the setting is definitely invalid, then we can throw an InvalidProviderSetting even earlier, during provider instantiation itself.