Skip to content

Comments

fix(xlib): handle None return from get_wm_name() on KDE Plasma#115

Merged
ErikBjare merged 1 commit intoActivityWatch:masterfrom
TimeToBuildBob:fix/xlib-none-guard
Feb 20, 2026
Merged

fix(xlib): handle None return from get_wm_name() on KDE Plasma#115
ErikBjare merged 1 commit intoActivityWatch:masterfrom
TimeToBuildBob:fix/xlib-none-guard

Conversation

@TimeToBuildBob
Copy link
Contributor

@TimeToBuildBob TimeToBuildBob commented Feb 20, 2026

Summary

Fixes #114AttributeError: 'NoneType' object has no attribute 'decode' crash on Fedora KDE Plasma.

Root cause: window.get_wm_name() can return None when no WM_NAME property exists on a window (common on KDE Plasma). The isinstance(r, str) check doesn't catch None, so it falls through to r.decode("latin1") which crashes.

Fix: Add a None guard that returns "unknown", matching the existing error handling pattern in the function.

Changes

  • aw_watcher_window/xlib.py: Added if r is None: return "unknown" check before the isinstance(r, str) branch in get_window_name()

Test plan

  • Verify the fix handles the None case correctly (returns "unknown" instead of crashing)
  • Test on KDE Plasma desktop with Fedora (reporter can verify)

Important

Fixes AttributeError in get_window_name() by handling None return from window.get_wm_name() in aw_watcher_window/xlib.py.

  • Behavior:
    • Fixes AttributeError in get_window_name() in aw_watcher_window/xlib.py by adding if r is None: return "unknown" to handle None return from window.get_wm_name().
  • Test Plan:
    • Verify fix on KDE Plasma to ensure it returns "unknown" instead of crashing.

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

When no WM_NAME property exists on a window (common on KDE Plasma with
Fedora), window.get_wm_name() returns None. The isinstance(r, str)
check doesn't catch None, so it falls through to r.decode("latin1")
which raises AttributeError: 'NoneType' object has no attribute 'decode'.

Add a None guard that returns "unknown", matching the existing error
handling pattern in the function.

Fixes ActivityWatch#114
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 3881c92 in 25 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_ZDkAJ2plVIbxJq6b

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 20, 2026

Greptile Summary

Fixed AttributeError crash on KDE Plasma by adding a None guard in get_window_name() before attempting to decode the window name.

  • Added explicit None check for window.get_wm_name() return value
  • Returns "unknown" when WM_NAME property is missing, consistent with other error handling in the function
  • Prevents crash from calling .decode() on NoneType

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is a simple defensive check that prevents a crash by handling the None case explicitly. It follows the existing error handling pattern in the function, returning "unknown" just like other error paths. The change is minimal (2 lines), well-targeted, and directly addresses the reported issue without introducing side effects.
  • No files require special attention

Important Files Changed

Filename Overview
aw_watcher_window/xlib.py Added None guard to prevent AttributeError when get_wm_name() returns None on KDE Plasma

Last reviewed commit: 3881c92

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

@ErikBjare
Copy link
Member

@TimeToBuildBob Looks like a seperate PR is needed to update the actions versions

@TimeToBuildBob
Copy link
Contributor Author

CI Note — Pre-existing Windows Failure

The test on windows-latest (py-3.9) check fails immediately with:

This request has been automatically failed because it uses a deprecated version of actions/upload-artifact: v3

This is a pre-existing CI infrastructure issue unrelated to this PR's changes — the repo's .github/workflows/build.yml still uses actions/upload-artifact@v3 which GitHub deprecated on April 16, 2024 and is now auto-failing. All other checks pass (typecheck ✅, CodeQL ✅, Greptile LGTM ✅, Ellipsis LGTM ✅).

I'll open a separate PR to upgrade the workflow to actions/upload-artifact@v4 so this doesn't block merging.

@ErikBjare ErikBjare merged commit 9e8fba1 into ActivityWatch:master Feb 20, 2026
3 of 6 checks passed
@TimeToBuildBob
Copy link
Contributor Author

Done — PR #116 (#116) upgrades actions/upload-artifact@v3v4. Greptile 5/5 confidence (safe to merge), Ellipsis LGTM. Once that's in, the Windows CI failure here goes away.

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.

Fedora 43 KDE Plasma: Exception thrown while trying to get active window

2 participants