Bug Description
When the ~/.limacharlie credentials file exists but is empty (0 bytes), the SDK crashes with an unhandled AttributeError instead of providing a helpful error message.
Steps to Reproduce
- Create an empty credentials file:
touch ~/.limacharlie
- Run any
limacharlie CLI command (e.g., limacharlie org list)
Expected Behavior
The SDK should detect the empty/invalid credentials file and display a helpful error message, e.g.:
"Credentials file ~/.limacharlie is empty or corrupted. Run 'limacharlie auth login' to reconfigure."
Actual Behavior
Traceback (most recent call last):
File "/home/user/.local/bin/limacharlie", line 5, in <module>
from limacharlie.__main__ import main
File "/home/user/.local/lib/python3.11/site-packages/limacharlie/__init__.py", line 54, in <module>
GLOBAL_OID, GLOBAL_UID, GLOBAL_API_KEY = _getEnvironmentCreds( _lcEnv )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.11/site-packages/limacharlie/__init__.py", line 27, in _getEnvironmentCreds
oid = credsFile.get( 'oid', None )
^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
Root Cause
In __init__.py, _getEnvironmentCreds reads the credentials file and parses it. When the file is empty, the parser returns None, but the code assumes it will always be a dict and calls .get() on it without a null check.
Suggested Fix
Add a guard after parsing the credentials file:
if credsFile is None:
credsFile = {}
Or raise a descriptive error prompting the user to re-authenticate.
Environment
- limacharlie version: 5.0.2
- Python version: 3.11
- OS: Linux
Bug Description
When the
~/.limacharliecredentials file exists but is empty (0 bytes), the SDK crashes with an unhandledAttributeErrorinstead of providing a helpful error message.Steps to Reproduce
touch ~/.limacharlielimacharlieCLI command (e.g.,limacharlie org list)Expected Behavior
The SDK should detect the empty/invalid credentials file and display a helpful error message, e.g.:
Actual Behavior
Root Cause
In
__init__.py,_getEnvironmentCredsreads the credentials file and parses it. When the file is empty, the parser returnsNone, but the code assumes it will always be a dict and calls.get()on it without a null check.Suggested Fix
Add a guard after parsing the credentials file:
Or raise a descriptive error prompting the user to re-authenticate.
Environment