ccsync icon indicating copy to clipboard operation
ccsync copied to clipboard

Fix Issues in edit_task.go — Double Date Formatting and Redundant Annotation Block Execution

Open inderjeet20 opened this issue 8 months ago • 1 comments

Description:

The edit_task.go file in the Taskwarrior (tw) layer contains two critical issues that need to be addressed:

  1. Double Date Formatting Produces Invalid Datetimes
    The file appends T00:00:00 to all date strings, even when the controller has already converted ISO dates to Taskwarrior format. This results in invalid datetime strings like "2026-01-28T14:30:00T00:00:00", which Taskwarrior rejects.

  2. Redundant Annotation Block Execution
    The condition len(annotations) >= 0 is always true, causing the annotation regeneration block to execute unnecessarily, even when no annotations are provided. This leads to redundant operations, such as deleting and re-adding all existing annotations.


Steps to Reproduce:

  1. For Double Date Formatting:

    • Submit a request to edit a task with a wait or due field containing a full ISO datetime (e.g., "2026-01-28T14:30:00").
    • Observe that the resulting Taskwarrior command includes an invalid datetime string.
  2. For Redundant Annotation Block Execution:

    • Submit a request to edit a task without any annotations.
    • Observe that the annotation regeneration block is executed, deleting and re-adding all existing annotations.

Expected Behavior:

  1. Double Date Formatting:

    • The edit_task.go file should only append T00:00:00 to date-only strings (e.g., "2026-01-28") and leave full datetime strings unchanged.
  2. Annotation Block Execution:

    • The annotation regeneration block should only execute when len(annotations) > 0.

Actual Behavior:

  1. Double Date Formatting:

    • The edit_task.go file appends T00:00:00 to all date strings, resulting in invalid datetime strings.
  2. Annotation Block Execution:

    • The annotation regeneration block executes regardless of whether annotations are provided, due to the len(annotations) >= 0 condition.

Suggested Fix:

  1. Double Date Formatting:

    • Add a check in edit_task.go to determine whether the input string is a date-only string or a full datetime string before appending T00:00:00.
  2. Annotation Block Execution:

    • Update the condition to len(annotations) > 0 to ensure the block only executes when annotations are provided.

File:

  • backend/utils/tw/edit_task.go

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

inderjeet20 avatar Mar 07 '26 07:03 inderjeet20

@Pavel401 @its-me-abhishek please review this pr

inderjeet20 avatar Mar 07 '26 08:03 inderjeet20