Skip to content

Fix duplicate Todo List item IDs (TODO_ITEM_DUPLICATE)#30710

Open
Laky-64 wants to merge 1 commit into
telegramdesktop:devfrom
Laky-64:patch-1
Open

Fix duplicate Todo List item IDs (TODO_ITEM_DUPLICATE)#30710
Laky-64 wants to merge 1 commit into
telegramdesktop:devfrom
Laky-64:patch-1

Conversation

@Laky-64
Copy link
Copy Markdown

@Laky-64 Laky-64 commented May 21, 2026

Fix duplicate Todo List item IDs (TODO_ITEM_DUPLICATE)

This PR fixes an issue in Todo List item ID generation that could lead to duplicate IDs being produced and rejected by Telegram with the TODO_ITEM_DUPLICATE error.

Problem

Previously, usedId was directly overwritten whenever a task already had an ID:

if (const auto id = task->id()) {
    usedId = id;
}

This caused a regression scenario when tasks were not strictly ordered by ascending IDs.
For example, if a task with a smaller existing ID appeared after a larger one, usedId would move backwards, allowing newly generated IDs to collide with already used IDs.

Fix

The new logic ensures that usedId always keeps the highest ID encountered so far:

if (const auto id = task->id()) {
    usedId = id > usedId ? id : usedId;
}

This guarantees that auto-generated IDs continue monotonically and prevents duplicate Todo List item IDs from being generated.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 21, 2026

CLA assistant check
All committers have signed the CLA.

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.

2 participants