Skip to content

Bug: Cron disable fails with 'The data couldn't be written because it isn't in correct format' #205

@austinm911

Description

@austinm911

Description

When trying to disable cron jobs in the Clawdbot UI, users encounter the error: "The data couldn't be written because it isn't in the correct format".

Steps to Reproduce

  1. Open Clawdbot Web UI or macOS app
  2. Navigate to the Cron section
  3. Try to disable an existing cron job by clicking the "Disable" button
  4. Error appears: "The data couldn't be written because it isn't in the correct format"

Expected Behavior

  • Cron job should be successfully disabled (enabled: false)
  • Job should be updated in the persistent store
  • UI should reflect the change without errors

Actual Behavior

  • Error message appears when trying to disable cron jobs
  • Job remains unchanged in the UI
  • No error details provided to help diagnose the issue

Environment Information

  • Clawdbot Version: [Latest]
  • Platform: [macOS/Linux/Windows]
  • Browser: [Chrome/Safari/Firefox]
  • Gateway Running: Yes

Investigation Notes

Based on codebase analysis, the error message "The data couldn't be written because it isn't in the correct format" is NOT found in the current Clawdbot codebase, suggesting this error originates from:

  1. Client-side validation in the Web UI
  2. Browser/storage limitations
  3. External dependencies (JSON5 parsing, file system)
  4. AJV validation failures in the Gateway API

Potential Root Causes

  1. JSON5 Parsing Issues (src/cron/store.ts:25)

    • Corrupted cron job data in ~/.clawdbot/cron/jobs.json
    • Invalid JSON5 syntax causing parse failures
    • Race conditions during concurrent writes
  2. AJV Validation Failures (src/gateway/server-methods/cron.ts:89-109)

    • Cron update payload failing TypeBox schema validation
    • Missing required fields in the patch operation
    • Type mismatches in boolean field validation
  3. File System Issues (src/cron/store.ts:36-47)

    • Disk space or permission issues
    • Concurrent access to the jobs.json file
    • Temporary file creation failures
  4. Client-Side Validation

    • Browser-specific data formatting issues
    • Form validation before sending to Gateway

Debugging Steps for Users

1. Check Gateway Logs

# View recent gateway logs for cron-related errors
./scripts/clawlog.sh --category cron

# Or follow logs in real-time
./scripts/clawlog.sh --follow --category cron

2. Check Browser Console

  1. Open Developer Tools (F12)
  2. Go to Console tab
  3. Try disabling the cron job again
  4. Look for JavaScript errors or failed network requests

3. Verify Cron Store Integrity

# Check if jobs.json exists and is valid
cat ~/.clawdbot/cron/jobs.json

# Validate JSON5 syntax (if json5 CLI tool available)
json5 parse ~/.clawdbot/cron/jobs.json

4. Test via CLI

# Try disabling via CLI to isolate if it's a UI issue
clawdbot cron list
clawdbot cron disable <job-id>

Requested Information

When reporting this issue, please provide:

  1. Browser Console Output: Any JavaScript errors
  2. Gateway Logs: Logs from the time the error occurred
  3. Cron Jobs Content: Contents of ~/.clawdbot/cron/jobs.json (sanitized)
  4. Network Tab: Any failed HTTP requests from browser DevTools

Temporary Workarounds

  1. Use CLI instead of UI:

    clawdbot cron disable <job-id>
  2. Manually edit jobs.json (advanced):

    # Stop gateway first
    # Backup the file
    cp ~/.clawdbot/cron/jobs.json ~/.clawdbot/cron/jobs.json.bak
    
    # Edit the enabled field to false for the problematic job
    # Restart gateway
  3. Remove and recreate the job:

    clawdbot cron rm <job-id>
    # Then recreate it with enabled=false

Code Areas to Investigate

  • src/cron/store.ts: JSON5 parsing and file operations
  • src/gateway/server-methods/cron.ts: AJV validation in cron.update
  • ui/src/ui/controllers/cron.ts: Client-side validation in toggleCronJob
  • ui/src/ui/views/cron.ts: Form handling and error display

Severity

High - Users cannot manage existing cron jobs, affecting automation functionality.

Priority

High - Core functionality is broken for cron management.

Screenshots

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions