Skip to content

fix: only update item fields when flags are explicitly set#283

Open
natustx wants to merge 1 commit intosachaos:masterfrom
natustx:fix/modify-flag-overwrite
Open

fix: only update item fields when flags are explicitly set#283
natustx wants to merge 1 commit intosachaos:masterfrom
natustx:fix/modify-flag-overwrite

Conversation

@natustx
Copy link

@natustx natustx commented Jan 27, 2026

Summary

  • Fix todoist modify overwriting all item fields with empty values when flags aren't provided
  • Only update content, priority, labels, and due date when their respective flags are explicitly set
  • Filter empty strings from label-names to prevent sending [""] to the API

Problem

Previously, running todoist modify abc123 -d tomorrow would:

  • ✅ Set due date to "tomorrow"
  • ❌ Clear content to ""
  • ❌ Clear labels to empty
  • ❌ Reset priority to 0

This happened because the code unconditionally overwrote all fields regardless of whether flags were provided.

Solution

Use c.IsSet() to check if each flag was explicitly provided before modifying the corresponding field.

Test plan

  • Run todoist modify <id> -d tomorrow and verify only due date changes
  • Run todoist modify <id> -c "new content" and verify only content changes
  • Run todoist modify <id> -p 1 and verify only priority changes
  • Run todoist modify <id> --label-names "label1,label2" and verify only labels change

Previously, `todoist modify <id>` would overwrite all item fields
(content, priority, labels, due date) with empty/default values
even when those flags weren't provided.

For example, `todoist modify abc123 -d tomorrow` would:
- Set due date to "tomorrow" ✓
- Clear content to "" (unintended)
- Clear labels to empty (unintended)
- Reset priority to 0 (unintended)

Now each field is only updated if the corresponding flag is
explicitly set via `c.IsSet()`.

Also filters empty strings from label-names to prevent sending
[""] when the flag value is empty.
@jenssegers
Copy link

Running into this issue as well!

@Trevortds
Copy link

I was expecting this might help my issue with the modify command (#287), but building from your fork the issue persists: the modify command does not work at all. Not in this branch, and not in the upstream.

@kenliu kenliu added the AI-generated label for any issue or PR that is either explicitly or looks like AI-generated content label Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-generated label for any issue or PR that is either explicitly or looks like AI-generated content

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants