fix: handle None return from get_setting in get_classes#102
fix: handle None return from get_setting in get_classes#102ErikBjare merged 3 commits intoActivityWatch:masterfrom
Conversation
When the "classes" setting exists on the server but has a null/empty value, get_setting returns None without raising an exception. The subsequent list comprehension then fails with: TypeError: 'NoneType' object is not iterable Add a None/empty guard to fall back to default_classes, matching the existing exception-handling behavior. Fixes ActivityWatch/activitywatch#1186
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to 6cf24eb in 7 seconds. Click for details.
- Reviewed
15lines of code in1files - Skipped
0files when reviewing. - Skipped posting
0draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
Workflow ID: wflow_KRLSRHStIBJDGw62
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Greptile SummaryFixes a Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 6cf24eb |
Python 3.9 is no longer available in the GitHub Actions runner toolcache. Update to 3.10 which is the oldest supported version available. Also bump actions/checkout to v3 and actions/setup-python to v4.
|
CI was failing due to two pre-existing issues unrelated to the bug fix:
CI runs are showing |
Summary
TypeError: 'NoneType' object is not iterablecrash inget_classes()when the server returnsNonefor the "classes" settingDetails
When
get_setting("classes")returnsNone(instead of raising an exception), the list comprehension on line 84 crashes with:This happens on fresh installs or when the "classes" setting exists but has no value set. The fix adds a
None/empty guard that falls back todefault_classes, consistent with the existing exception-handling path.Reported in: ActivityWatch/activitywatch#1186
Test plan
None, empty list[], and valid class lists correctlyImportant
Fixes
TypeErroringet_classes()by handlingNonereturn fromget_settingand usingdefault_classesas fallback.TypeErroringet_classes()inclasses.pywhenget_setting("classes")returnsNone.Noneor emptyclasses, logging a warning and returningdefault_classesas fallback.classessetting is empty or unset, consistent with exception handling path.This description was created by
for 6cf24eb. You can customize this summary. It will automatically update as commits are pushed.