Skip to content

Fix: Deserialization error for todo items missing priority field#1

Open
arcalumis wants to merge 1 commit into
melonicecream:mainfrom
arcalumis:bugfix/priority-error
Open

Fix: Deserialization error for todo items missing priority field#1
arcalumis wants to merge 1 commit into
melonicecream:mainfrom
arcalumis:bugfix/priority-error

Conversation

@arcalumis
Copy link
Copy Markdown

Summary

  • Fixes "Error: missing field priority at line 6 column 3" that occurs when running cc-enhanced
  • Makes the priority field optional with a default value for backward compatibility

Problem

When running cc-enhanced, users encountered the error:

Error: missing field `priority` at line 6 column 3

This happened because:

  1. Some older todo files in ~/.claude/todos/ were created before the priority field was added to the TodoItem struct
  2. The serde deserializer expected all fields to be present, causing it to fail when parsing these legacy files
  3. The error occurred specifically in TodoManager::parse_todo_file() when calling serde_json::from_str(&content)?

Root Cause Analysis

The error occurs in src/features/todos/data.rs at line 147:

let todos: Vec<TodoItem> = serde_json::from_str(&content)?;

When parsing todo files like /Users/baud/.claude/todos/5ab42a40-9260-406f-8b72-20b8610aa918-agent-5ab42a40-9260-406f-8b72-20b8610aa918.json, which contain:

[
  {
    "content": "Check current voice mode configuration",
    "status": "completed",
    "id": "1"
  },
  {
    "content": "List available TTS voices", 
    "status": "completed",
    "id": "2"
  }
]

The deserializer fails because the TodoItem struct requires a priority field that doesn't exist in these legacy files.

Solution

  • Added #[serde(default = "default_priority")] attribute to the priority field in the TodoItem struct
  • Created a default_priority() function that returns TodoPriority::Medium as the fallback value
  • This provides full backward compatibility with existing todo files while maintaining current functionality

Testing

  • ✅ Verified that cc-enhanced now runs successfully without the deserialization error
  • ✅ Tested with existing todo files that were missing the priority field
  • ✅ Confirmed that new todo files continue to work as expected
  • ✅ All existing functionality remains intact

Files Changed

  • src/features/todos/data.rs - Made priority field optional with default value

🤖 Generated with Claude Code

When running cc-enhanced, users encountered the error:
"Error: missing field `priority` at line 6 column 3"

This occurred because some older todo files in ~/.claude/todos/ were
created before the priority field was added to the TodoItem struct,
causing serde deserialization to fail.

The fix makes the priority field optional using serde's default
attribute, providing a fallback value of Medium priority for
backward compatibility with existing todo files.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@pablopunk pablopunk mentioned this pull request Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant