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
- Open ActivityWatch web UI at
http://localhost:5600
- Go to Settings → Classes
- Create a new category, or edit an existing sub-category
- Change its Parent to "None" (or leave it empty)
- Save
- Go back to any view that displays charts (e.g. Summary)
- All charts fail to load
- Check server log →
Tried to reference variable 'null' which is not defined
- Open
%LOCALAPPDATA%\ActivityWatch\activitywatch\aw-server\settings.json → classes[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:
-
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.
-
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.
Category Editor writes
nullinto class name array when parent is "None", breaking all chartsVersion: 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
nullinto the classnamearray insettings.json. Thisnullis then serialized into thecategorize()query sent to/api/0/query/, and the query engine interpretsnullas a variable name reference, throwingQueryInterpretException: Tried to reference variable 'null' which is not defined. All charts that usecategorize()fail to load.To Reproduce
http://localhost:5600Tried to reference variable 'null' which is not defined%LOCALAPPDATA%\ActivityWatch\activitywatch\aw-server\settings.json→classes[i].namecontainsnullBroken 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
Root cause
There are two problems:
Frontend (aw-webui): When a category has no parent (root level), the Category Editor writes
nullas the first element of thenamearray. This is likely because the parent selector value isnullorundefinedand gets concatenated into the name array instead of being omitted or replaced with an empty string.Backend (aw_query): The
q2_categorizefunction inaw_query/functions.pyreceives thesenullvalues and passes them to the query interpreter, which parses them as variable name references (null→ try to look up variablenull). The backend should either:nullvalues in category names with a clear error, orWorkaround
Manually edit
%LOCALAPPDATA%\ActivityWatch\activitywatch\aw-server\settings.jsonand remove allnullentries fromclasses[].namearrays:[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
aw-webui/src/store/categories.tsoraw-webui/src/components/CategoryEditor.vue— when saving a root-level category, the parent value should not be serialized asnullinto thenamearray.aw_query/functions.pyaroundq2_categorize— filter outnull/Noneentries from category name paths as a safety measure.