fix: queue daemon crashes on every task (issue #174) #175

Merged
shoko merged 1 commits from fix/issue-174-queue-daemon-crashes into main 2026-04-06 04:16:12 +02:00
Owner

Summary

Fix 3 bugs from issue #174 that caused silent failure loop where tasks are immediately marked error and the daemon cycles endlessly.

Bug 1 — json.loads with newlines

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

Problem: Notifications JSON was embedded in a single-quoted Python string literal, but newlines in the JSON (after pretty-printing) broke the Python parser.

Fix: Pass JSON via stdin to Python instead of embedding in string.

Bug 2 — logs directory not created

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

Problem: log_file = ~/.kugetsu/logs/delegate-.log but the logs/ directory was never created during kugetsu init.

Fix: Add mkdir -p for LOGS_DIR, WORKTREES_DIR, QUEUE_DIR, and QUEUE_ITEMS_DIR to ensure_dirs() and ensure_queue_dirs().

Bug 3 — issue_ref parsed incorrectly from URL format

File: kugetsu script, parse_issue_ref_from_message() function.

Problem: When parsing #158, the function used buggy grep/sed that incorrectly extracted the instance.

Fix: Use bash regex (=~) for reliable URL parsing with proper capture groups.

Testing

  • Verified multiline messages are correctly handled in kugetsu_add_notification()
  • Verified URL parsing returns correct format instance|owner|repo|issue_number
  • Verified ensure_dirs() creates all required directories

References

## Summary Fix 3 bugs from issue #174 that caused silent failure loop where tasks are immediately marked error and the daemon cycles endlessly. ### Bug 1 — json.loads with newlines File: kugetsu-log.sh, kugetsu_add_notification() function. Problem: Notifications JSON was embedded in a single-quoted Python string literal, but newlines in the JSON (after pretty-printing) broke the Python parser. Fix: Pass JSON via stdin to Python instead of embedding in string. ### Bug 2 — logs directory not created File: kugetsu-queue-daemon.sh line 114/125. Problem: log_file = ~/.kugetsu/logs/delegate-<timestamp>.log but the logs/ directory was never created during kugetsu init. Fix: Add mkdir -p for LOGS_DIR, WORKTREES_DIR, QUEUE_DIR, and QUEUE_ITEMS_DIR to ensure_dirs() and ensure_queue_dirs(). ### Bug 3 — issue_ref parsed incorrectly from URL format File: kugetsu script, parse_issue_ref_from_message() function. Problem: When parsing https://git.fbrns.co/shoko/kugetsu/issues/158, the function used buggy grep/sed that incorrectly extracted the instance. Fix: Use bash regex (=~) for reliable URL parsing with proper capture groups. ## Testing - Verified multiline messages are correctly handled in kugetsu_add_notification() - Verified URL parsing returns correct format instance|owner|repo|issue_number - Verified ensure_dirs() creates all required directories ## References - Fixes #174
shoko added 1 commit 2026-04-06 04:11:10 +02:00
Fix 3 bugs from issue #174 that caused silent failure loop:

1. kugetsu-log.sh: Fix json.loads with newlines
   - Previously, notifications JSON was embedded in a single-quoted Python
     string literal, but newlines in the JSON broke the Python parser.
   - Fix: Pass JSON via stdin to Python instead of embedding in string.

2. kugetsu-queue-daemon.sh: Create logs directory during init
   - The logs/ directory ($LOGS_DIR) was never created during kugetsu init.
   - Fix: Add mkdir -p for LOGS_DIR, WORKTREES_DIR, QUEUE_DIR, and
     QUEUE_ITEMS_DIR to ensure_dirs() and ensure_queue_dirs().

3. kugetsu: Fix parse_issue_ref_from_message URL parsing
   - The function used buggy grep/sed to parse URLs like
     #158
   - Fix: Use bash regex (=~) for reliable URL parsing with proper
     capture groups.

Additional improvements:
   - ensure_dirs() now creates all necessary directories instead of just
     SESSIONS_DIR
   - ensure_queue_dirs() now also creates QUEUE_DIR and LOGS_DIR
   - parse_issue_ref_from_message uses consistent bash regex approach
     for all URL patterns
shoko force-pushed fix/issue-174-queue-daemon-crashes from c1385f22fd to fb33be3a64 2026-04-06 04:14:36 +02:00 Compare
han approved these changes 2026-04-06 04:15:50 +02:00
han left a comment
First-time contributor

lgtm

lgtm
shoko merged commit 56310755b8 into main 2026-04-06 04:16:12 +02:00
Sign in to join this conversation.