Queue daemon crashes on every task — silent failure loop #174

Closed
opened 2026-04-06 03:50:26 +02:00 by shoko · 1 comment
Owner

Summary

Queue daemon crashes on every task due to two bugs that cause a silent failure loop. Tasks are immediately marked error and the daemon cycles endlessly.

Bugs

Bug 1 — kugetsu-log.sh:54 json.loads with newlines

File: kugetsu-log.sh, kugetsu_add_notification() function.

Root cause: Notifications JSON is embedded in a single-quoted Python string literal, but it contains newlines which break the Python parser:

notifications=$(python3 -c "import json; n=json.loads(); ...")

When $notifications contains JSON with newlines (which it always does after the first notification), Python sees:

json.loads([n
## Summary Queue daemon crashes on every task due to two bugs that cause a silent failure loop. Tasks are immediately marked `error` and the daemon cycles endlessly. ## Bugs ### Bug 1 — kugetsu-log.sh:54 json.loads with newlines **File:** `kugetsu-log.sh`, `kugetsu_add_notification()` function. **Root cause:** Notifications JSON is embedded in a single-quoted Python string literal, but it contains newlines which break the Python parser: ```bash notifications=$(python3 -c "import json; n=json.loads(); ...") ``` When `$notifications` contains JSON with newlines (which it always does after the first notification), Python sees: ``` json.loads([n
Author
Owner

Additional Bugs Found

Bug 2 — logs directory not created

File: kugetsu-queue-daemon.sh line 114/125.

if cmd_start "$issue_ref" "$message" >> "$log_file" 2>&1; then

$log_file = ~/.kugetsu/logs/delegate-<timestamp>.log but the logs/ directory is never created during kugetsu init. Result:

/home/shoko/.kugetsu/logs/delegate-1775439628.log: No such file or directory

Every task immediately fails because the log file cannot be written.

Fix: Add mkdir -p ~/.kugetsu/logs/ during kugetsu init or in the daemon startup.


Bug 3 — issue_ref parsed incorrectly from URL format

File: kugetsu script, parse_issue_ref_from_message() function.

When delegating with a full URL like:

https://git.fbrns.co/shoko/kugetsu/issues/158

The parsed issue_ref becomes:

"shoko/kugetsu/issues#158"   ← wrong (missing instance, wrong separator)

Instead of the correct format:

"git.fbrns.co/shoko/kugetsu#158"

Root cause: parse_issue_ref_from_message() only handles the #number format at the end of messages. The /issues/NUMBER URL pattern gets the instance stripped and /issues/ kept in the path.

Fix: Add explicit handling for instance/user/repo/issues/NUMBER URL pattern.

## Additional Bugs Found ### Bug 2 — logs directory not created **File:** `kugetsu-queue-daemon.sh` line 114/125. ```bash if cmd_start "$issue_ref" "$message" >> "$log_file" 2>&1; then ``` `$log_file` = `~/.kugetsu/logs/delegate-<timestamp>.log` but the `logs/` directory is never created during `kugetsu init`. Result: ``` /home/shoko/.kugetsu/logs/delegate-1775439628.log: No such file or directory ``` Every task immediately fails because the log file cannot be written. **Fix:** Add `mkdir -p ~/.kugetsu/logs/` during `kugetsu init` or in the daemon startup. --- ### Bug 3 — issue_ref parsed incorrectly from URL format **File:** `kugetsu` script, `parse_issue_ref_from_message()` function. When delegating with a full URL like: ``` https://git.fbrns.co/shoko/kugetsu/issues/158 ``` The parsed `issue_ref` becomes: ``` "shoko/kugetsu/issues#158" ← wrong (missing instance, wrong separator) ``` Instead of the correct format: ``` "git.fbrns.co/shoko/kugetsu#158" ``` **Root cause:** `parse_issue_ref_from_message()` only handles the `#number` format at the end of messages. The `/issues/NUMBER` URL pattern gets the instance stripped and `/issues/` kept in the path. **Fix:** Add explicit handling for `instance/user/repo/issues/NUMBER` URL pattern.
shoko closed this issue 2026-04-06 04:16:12 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/kugetsu#174