Skip to content

fix: backfill Todoist labels when incremental sync returns empty#2304

Closed
Blacksuan19 wants to merge 1 commit intoalainm23:mainfrom
Blacksuan19:fix-missing-remote-labels
Closed

fix: backfill Todoist labels when incremental sync returns empty#2304
Blacksuan19 wants to merge 1 commit intoalainm23:mainfrom
Blacksuan19:fix-missing-remote-labels

Conversation

@Blacksuan19
Copy link

Summary

Fixes an issue where Todoist labels could be missing in Planify if incremental sync returned an empty labels payload.

What changed

  • Added a one-time labels backfill in Services.Todoist.sync():
    • If delta sync has no labels, fetch labels with:
      • sync_token=*
      • resource_types=["labels"]
    • Upsert returned labels into local store.
  • Improved item label parsing in Objects.Item:
    • Resolve label values by id first, then by name.
    • Skip unresolved labels safely.

Why

On some accounts, incremental sync can omit label entries even when labels exist server-side. Without a full labels refresh, Planify never repopulates missing labels.

Validation

  • Reproduced issue with labels created outside Planify not appearing.
  • After fix:
    • labels are fetched via backfill,
    • labels appear in Labels view and task assignments,
    • label changes continue syncing normally.
  • Build/test:
    • ninja -C build
    • ninja -C build test (all passing)

Testing

Manual end-to-end validation against a real Todoist account:

  • Modified existing labels in Planify and verified changes synced to Todoist.
  • Modified existing labels in Todoist and verified changes synced to Planify.
  • Created labels in Planify and verified they appeared in Todoist.
  • Created labels in Todoist and verified they appeared in Planify.
  • Deleted labels in Planify and verified deletion synced to Todoist.
  • Deleted labels in Todoist and verified deletion synced to Planify.
  • Verified task label assignments remained correct after each operation.

Result: all label create/update/delete flows worked as expected in both directions.

Related

Some Todoist accounts can return an empty `labels` collection during
incremental sync, which leaves Planify with missing local labels even
though labels exist server-side.

This change adds a one-time per-source labels backfill:
- when delta sync returns no labels, request `resource_types=["labels"]`
  with `sync_token=*`
- merge the returned labels into the local store
- keep normal incremental sync unchanged

Also hardens item label resolution by:
- resolving labels by id first, then by name
- skipping unresolved labels safely to avoid null label entries

Result:
- labels created outside Planify are loaded correctly
- labels appear on tasks and in label pickers after sync
- normal label create/update flows continue to work

Signed-off-by: blacksuan19 <abubakaryagob@gmail.com>
@github-actions
Copy link
Contributor

Translation files need updating

  • Apply translation updates

Copy link
Collaborator

@byquanton byquanton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a very hacky way to fetch labels once per runtime during synchronisation. It also shouldn't be necessary to make an extra request just for the labels.

@Blacksuan19
Copy link
Author

removing and adding account again fixed label sync, closing this now.

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.

Labels from todoist not being loaded

2 participants