activitywatch icon indicating copy to clipboard operation
activitywatch copied to clipboard

Failed to save categories after import, adding, editing or remove

Open frankBahlsen opened this issue 1 month ago • 4 comments

Pre-submission checklist

OS

Windows 11 Pro 10.0.26200

ActivityWatch version

v0.14.1

Describe the bug

First after importing the "aw-category-export.json" an clicking the "save"-Button it appears an error message with these information: "Failed to save categories (HTTP 500): Request failed with status code 500". Furthermore, it is no longer possible to delete categories or save newly created ones.

Restart of aw in taskbar doesn't fix the problem.

Steps to reproduce

  1. Go to "http://localhost:5600/#/settings/categorization"
  2. Click on "import" or "add category"
  3. Get Error Message
  4. Close browser tab and goto step 1

Expected behavior

"Saved" message displayed and new categories saved, changed or deleted

Logs, screenshots, or other documentation

aw-server_2026-10-20T18-09-19.log

Additional context

No response

frankBahlsen avatar Oct 20 '26 16:10 frankBahlsen

Hi there! As you're new to this repo, please make sure you've used an appropriate issue template and searched for duplicates (it helps us focus on actual development!). We'd also like to suggest that you read our contribution guidelines and our code of conduct. Thanks a bunch for opening your first issue! 🙏

github-actions[bot] avatar Oct 20 '26 16:10 github-actions[bot]

The log points to a settings-file write failure rather than a category-format error: PermissionError on settings.json recurs for locale and other settings too, while database heartbeats continue writing.

Could you check that file's attributes and whether it is a file rather than a folder? These read-only PowerShell commands use the directory shown in your log:

$p = Join-Path $env:LOCALAPPDATA 'activitywatch\activitywatch\aw-server\settings.json'
Get-Item -LiteralPath $p | Select-Object FullName, PSIsContainer, Attributes
attrib $p

Please share the attributes (you can redact your username). Don't delete the file or change permissions broadly; it contains your settings. A read-only attribute or a process holding the file are possible causes, not yet confirmed.

I opened ActivityWatch/aw-server#198 to preserve the previous settings on failed writes and return a more useful path/error message. Its 139 selected server tests pass locally, including failed writes, concurrent updates and symlink preservation. That PR is not released and does not establish the cause of your Windows permission denial, so this report stays open.

TimeToBuildBob avatar Oct 20 '26 18:10 TimeToBuildBob

Tested the #/settings/categorization import/add/edit/remove/save flow end-to-end on published v0.14.3 (aw-server + bundled WebUI, macOS 27.3 arm64, isolated HOME and --profile verify1537 --port 5698):

  • Writable settings.json: Importing an aw-category-export.json, adding, editing, and removing categories all save cleanly (HTTP 200) and persist across aw-server restarts.
  • Read-only settings.json (chmod 444) — backend (ActivityWatch/aw-server#198): Works as intended. POST /api/0/settings/classes preserves the previous categories in memory and on disk, logs the error (errno 13) plus the startup read-only warning on restart, and returns HTTP 500 with the actionable JSON body:
    {"message": "Unable to save settings to .../aw-server/settings.json: Settings file is read-only", "path": ".../aw-server/settings.json", "errno": 13}
    
  • WebUI gap still present in v0.14.3 and aw-webui master (af79fb1d): Even when aw-server returns that JSON body, clicking Save in #/settings/categorization still displays only the opaque alert from this issue:
    Failed to save categories (HTTP 500): Request failed with status code 500
    
    In ActivityWatch/aw-webui's src/views/settings/CategorizationSettings.vue (saveClasses), the catch block reads const detail = (e && e.message) || String(e); and never checks e?.response?.data?.message, so Axios's generic status message hides the server's settings.json path and reason.

Scope note: this does not diagnose the original Windows 11 PermissionError cause (still waiting on the file attributes requested above); it only flags that the improved aw-server#198 error detail isn't yet surfaced in the Categorization UI on v0.14.3.

(Disclosure: isolated testing and this verification note were prepared with AI assistance.)

KilianTheMagnificent avatar Nov 19 '26 03:11 KilianTheMagnificent

Thanks for the detailed verification. I confirmed the WebUI error-handling gap on current master and opened ActivityWatch/aw-webui#1294 to show the server's message (including the settings path and reason), while keeping the HTTP status and a fallback for older servers or network errors.

The mounted Save-button regression failed before the fix and passes afterward; 205 related tests pass locally. The PR is not merged or released, and CI/review are still running.

This improves diagnosis, not permissions. The original Windows failure remains open pending the file attributes requested above; no settings deletion or permission changes are needed to test this UI fix.

TimeToBuildBob avatar Nov 19 '26 03:11 TimeToBuildBob