Skip to content

fix: handle None return from get_setting in get_classes#102

Merged
ErikBjare merged 3 commits intoActivityWatch:masterfrom
TimeToBuildBob:fix/get-classes-nonetype
Feb 23, 2026
Merged

fix: handle None return from get_setting in get_classes#102
ErikBjare merged 3 commits intoActivityWatch:masterfrom
TimeToBuildBob:fix/get-classes-nonetype

Conversation

@TimeToBuildBob
Copy link
Contributor

@TimeToBuildBob TimeToBuildBob commented Feb 23, 2026

Summary

  • Fix TypeError: 'NoneType' object is not iterable crash in get_classes() when the server returns None for the "classes" setting

Details

When get_setting("classes") returns None (instead of raising an exception), the list comprehension on line 84 crashes with:

TypeError: 'NoneType' object is not iterable

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 to default_classes, consistent with the existing exception-handling path.

Reported in: ActivityWatch/activitywatch#1186

Test plan

  • Verified the fix handles None, empty list [], and valid class lists correctly
  • CI passes

Important

Fixes TypeError in get_classes() by handling None return from get_setting and using default_classes as fallback.

  • Behavior:
    • Fix TypeError in get_classes() in classes.py when get_setting("classes") returns None.
    • Adds a check for None or empty classes, logging a warning and returning default_classes as fallback.
  • Logging:
    • Logs a warning if classes setting is empty or unset, consistent with exception handling path.

This description was created by Ellipsis for 6cf24eb. You can customize this summary. It will automatically update as commits are pushed.

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
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to 6cf24eb in 7 seconds. Click for details.
  • Reviewed 15 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 draft 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 Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@greptile-apps
Copy link

greptile-apps bot commented Feb 23, 2026

Greptile Summary

Fixes a TypeError: 'NoneType' object is not iterable crash in get_classes() by adding a None/empty check before the list comprehension. When get_setting("classes") returns None or an empty list, the function now logs a warning and returns default_classes as a fallback, consistent with the existing exception handling path.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is straightforward, defensive, and follows the existing error handling pattern. It prevents a crash by adding a simple None/empty check before iterating, with proper logging and fallback behavior.
  • No files require special attention

Important Files Changed

Filename Overview
aw_client/classes.py Adds None-check to prevent TypeError when classes setting is unset, correctly falls back to default_classes

Last reviewed commit: 6cf24eb

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

TimeToBuildBob and others added 2 commits February 23, 2026 06:04
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.
@TimeToBuildBob
Copy link
Contributor Author

CI was failing due to two pre-existing issues unrelated to the bug fix:

  1. Black formatting (commit 2d1b136): Fixed trailing blank lines in examples/suggest_categories.py, examples/working_hours.py, and reformatted a long @click.option in aw_client/cli.py.

  2. Python 3.9 unavailable (commit 4dae34c): GitHub Actions no longer provides Python 3.9 in the runner toolcache. Updated .github/workflows/examples.yml to use Python 3.10 (oldest available), and bumped actions/checkout@v2 → v3 and actions/setup-python@v1 → v4.

CI runs are showing action_required — a maintainer needs to approve the CI workflow run for this fork branch before results are visible.

@ErikBjare ErikBjare merged commit f0603e3 into ActivityWatch:master Feb 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants