Skip to content

Category Editor writes null into class name array when parent is “None”, breaking all charts #1355

Description

@s13mjl

Category Editor writes null into class name array when parent is "None", breaking all charts

Version: v0.13.2 (Windows)

Describe the bug

When editing a category in Settings → Classes and setting its parent to "None" (i.e. making it a root-level category), the frontend writes null into the class name array in settings.json. This null is then serialized into the categorize() query sent to /api/0/query/, and the query engine interprets null as a variable name reference, throwing QueryInterpretException: Tried to reference variable 'null' which is not defined. All charts that use categorize() fail to load.

To Reproduce

  1. Open ActivityWatch web UI at http://localhost:5600
  2. Go to Settings → Classes
  3. Create a new category, or edit an existing sub-category
  4. Change its Parent to "None" (or leave it empty)
  5. Save
  6. Go back to any view that displays charts (e.g. Summary)
  7. All charts fail to load
  8. Check server log → Tried to reference variable 'null' which is not defined
  9. Open %LOCALAPPDATA%\ActivityWatch\activitywatch\aw-server\settings.jsonclasses[i].name contains null

Broken settings.json example

{
    "id": 0,
    "name": [null],
    "rule": {}
},
{
    "id": 1,
    "name": [null, "Programming"],
    "rule": {
        "regex": "GitHub|Stack Overflow|BitBucket|Gitlab|vim|Spyder|kate|Ghidra|Scite",
        "type": "regex"
    }
}

Server error

ERROR on /api/0/query/ [POST]
...
File "aw_query\functions.py", line 324, in q2_categorize
...
QueryInterpretException: Tried to reference variable 'null' which is not defined

Root cause

There are two problems:

  1. Frontend (aw-webui): When a category has no parent (root level), the Category Editor writes null as the first element of the name array. This is likely because the parent selector value is null or undefined and gets concatenated into the name array instead of being omitted or replaced with an empty string.

  2. Backend (aw_query): The q2_categorize function in aw_query/functions.py receives these null values and passes them to the query interpreter, which parses them as variable name references (null → try to look up variable null). The backend should either:

    • Reject null values in category names with a clear error, or
    • Strip/skip null entries in the name path

Workaround

Manually edit %LOCALAPPDATA%\ActivityWatch\activitywatch\aw-server\settings.json and remove all null entries from classes[].name arrays:

  • [null] → delete the class entirely (empty rule, no matching)
  • [null, "Programming"]["Programming"]
  • [null, "Programming", "ActivityWatch"]["Programming", "ActivityWatch"]

Then refresh the web UI. No server restart needed.

Likely fix location

  • Frontend: aw-webui/src/store/categories.ts or aw-webui/src/components/CategoryEditor.vue — when saving a root-level category, the parent value should not be serialized as null into the name array.
  • Backend: aw_query/functions.py around q2_categorize — filter out null/None entries from category name paths as a safety measure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions