LS Client crash when passing `None` as the `api_key`
GuilhermeFreire opened this issue · 0 comments
Describe the bug
If you pass None
as your api_key
and you don't have your LABEL_STUDIO_API_KEY
env var set when creating a label_studio_sdk.Client
, you'll get an AttributeError
when trying to access credentials.api_key
.
This happens because, the check for api_key
being None
and using credentials
is wrong on client.py:
label-studio-sdk/label_studio_sdk/client.py
Lines 83 to 92 in 415049a
To Reproduce
Run the following without setting your LABEL_STUDIO_API_KEY
env var.
>>> import label_studio_sdk
>>> label_studio_sdk.Client()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/path/to/label_studio_sdk/client.py", line 90, in __init__
if credentials.api_key
AttributeError: 'NoneType' object has no attribute 'api_key'
Expected behavior
Since you can't really do anything at this point (no api_key and no credentials), the SDK should just raise an error with a better error message. It's a small change and I could probably make a PR for it when I have some time 😅, but just thought of creating the issue in case anyone is able to fix this first.