Skip to content

Fix create_task silently dropping dates, reminders, and priority#11

Open
partymola wants to merge 1 commit into
jen6:mainfrom
partymola:fix/create-task-preserve-fields
Open

Fix create_task silently dropping dates, reminders, and priority#11
partymola wants to merge 1 commit into
jen6:mainfrom
partymola:fix/create-task-preserve-fields

Conversation

@partymola
Copy link
Copy Markdown

Problem

ticktick_create_task delegates to client.task.builder() from the ticktick-py library to construct the task dict, then passes it to client.task.create(). However, builder() silently drops fields it does not handle -- the values are accepted as parameters but never appear in the returned dict.

Failure scenarios

  • User creates a task with dueDate='2026-04-01T20:45:00+00:00'. The task is created successfully but with no due date -- it does not appear in TickTick's today/upcoming views and no reminder fires.
  • User creates a task with reminders=['TRIGGER:PT0S']. The task is created but without reminders, so no notification is sent at the due time.
  • User creates a task with priority=5 (high). The task is created with no priority set (appears as priority 0/none in TickTick).
  • User provides timeZone='Europe/London'. The timezone is not stored, so date display may be wrong for users not in the server's local timezone.

All of these fail silently -- the API returns success and the task exists, but the missing fields make it effectively invisible or misconfigured. The caller has no indication that anything went wrong.

Fix

After calling builder(), check whether each user-provided field is present in the resulting dict. If the builder omitted it, add it directly using the same conversion functions (convert_date_to_tick_tick_format for dates, raw values for reminders/priority/timeZone).

Fields already set by the builder are not overwritten, so this is safe even if a future version of ticktick-py fixes the builder.

Tests

14 unit tests added covering:

  • Dates included when builder omits them
  • Reminders included when builder omits them
  • Priority included when builder omits it (including explicit priority=0)
  • TimeZone included when builder omits it
  • Builder's existing output for dates/reminders/priority/timezone is NOT overwritten
  • No extra fields added when none were requested
  • priority=None (default) does not trigger fallback
  • Local timezone used as fallback for date conversion
  • Invalid date format returns error
  • Client exceptions return error

Problem
-------
ticktick_create_task delegates to client.task.builder() from the
ticktick-py library to construct the task dict, then passes it to
client.task.create(). However, builder() silently drops fields it does
not handle -- the values are accepted as parameters but never appear in
the returned dict.

Failure scenarios:
- User creates a task with dueDate='2026-04-01T20:45:00+00:00'. The
  task is created successfully but with no due date -- it does not
  appear in TickTick's today/upcoming views and no reminder fires.
- User creates a task with reminders=['TRIGGER:PT0S']. The task is
  created but without reminders, so no notification is sent.
- User creates a task with priority=5 (high). The task is created with
  no priority set (appears as priority 0/none in TickTick).
- User provides timeZone='Europe/London'. The timezone is not stored,
  so date display may be wrong for users not in the server's local tz.

All of these fail silently -- the API returns success and the task
exists, but the missing fields make it effectively invisible or
misconfigured. The caller has no indication that anything went wrong.

Fix
---
After calling builder(), check whether each user-provided field is
present in the resulting dict. If the builder omitted it, add it
directly using the same conversion functions (convert_date_to_tick_tick_
format for dates, raw values for reminders/priority/timeZone). Fields
already set by the builder are not overwritten, so this is safe even if
a future version of ticktick-py fixes the builder.

Add unit tests covering builder field gaps, preservation of existing
builder output, timezone fallback, and error handling.
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