fix: only update item fields when flags are explicitly set#283
Open
natustx wants to merge 1 commit intosachaos:masterfrom
Open
fix: only update item fields when flags are explicitly set#283natustx wants to merge 1 commit intosachaos:masterfrom
natustx wants to merge 1 commit intosachaos:masterfrom
Conversation
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.
|
Running into this issue as well! |
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
todoist modifyoverwriting all item fields with empty values when flags aren't provided[""]to the APIProblem
Previously, running
todoist modify abc123 -d tomorrowwould: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
todoist modify <id> -d tomorrowand verify only due date changestodoist modify <id> -c "new content"and verify only content changestodoist modify <id> -p 1and verify only priority changestodoist modify <id> --label-names "label1,label2"and verify only labels change