Skip to content

Fixes #36393: List tasks newest first by creation time - #36395

Merged
yan-3005 merged 4 commits into
mainfrom
yan-3005/collate-inc.-slack-message
Oct 28, 2026
Merged

yan-3005 merged 4 commits into
mainfrom
yan-3005/collate-inc.-slack-message

Conversation

@yan-3005

@yan-3005 yan-3005 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #36393

The Inbox Triage queue and the notification bell listed tasks oldest first. Every task list endpoint (/v1/tasks, /assigned, /visible, /owned, /created) paged by the generic (name, id) keyset in ascending order. Sorting by name descending would not fix it:

  • Task names are TASK-%05d strings compared as text, so TASK-100000 sorts before TASK-99999.
  • The 2.0 migration numbered every suggestion before any thread task, so on upgraded installs name order is not creation order.

The UI can't re-sort either, because it loads one cursor page at a time.

What changed:

  • New order. The five endpoints now page by a (createdAt, id) keyset, newest first. They take an optional sortOrder=asc|desc (default desc), mirroring /dataAccessRequests.
  • Opt-in through TaskListOrder. The order is set on the ListFilter by TaskListOrder.applyTo. Listings that don't set it keep the (name, id) keyset and name cursor. That includes the search reindex, whose offset-seeded cursors (getCursorAtOffset) depend on name order.
  • TaskDAO. Two keyset queries are added: one for the plain path, and one for the free-text search (q) path that keeps that path's filter-first plan (IGNORE INDEX on MySQL, MATERIALIZED CTE on Postgres). The bound is written createdAt <op>= c AND (createdAt <op> c OR id <op> i) so it stays a range on the existing createdAt index. A small Jdbi binder, @TaskListOrder.BindPage, supplies the operator, both sort directions and the cursor, so each query takes 4 parameters (the same pattern as @BindFQN). The change is purely additive: main's listAfter/listBefore branches and its name-ordered search SQL (listSearchAfter/listSearchBefore) are left as they are. Every list endpoint that sets q now pages by creation time, so nothing in OSS or Collate (origin/main, checked) reaches that name-ordered search SQL any more. That makes it a candidate for a separate cleanup, not this PR.
  • TaskRepository.getCursorValue(Task, ListFilter). Emits createdAt in the cursor's name slot only for creation-time listings.
  • Old cursors. A name cursor issued before this change now returns 400 with a clear message instead of a 500. A bad sortOrder also returns 400.
  • Decision record. ADR:2026-10-28-task-lists-page-newest-first-by-creation-time.

No UI change is needed. Triage, the notification bell, useMyTasks and the entity-page task tabs pick up newest-first through the default.

Type of change:

  • Bug fix

High-level design:

N/A — small change. The approach and the alternatives rejected are in docs/decisions/2026-10-28-task-lists-page-newest-first-by-creation-time.md:

  • Name descending: wrong past 99,999 tasks and on migrated installs.
  • A repository-wide order change: breaks reindex cursor seeding.
  • A client-side sort: wrong across pages.

Compatibility:

  • Default order flips for every client of these five endpoints.
  • A client holding a pre-upgrade after/before cursor gets 400 and must restart from the first page.
  • Cursor-based clients (Python task_mixin, Java SDK) don't depend on order.
  • No schema or migration changes.

Tests:

Use cases covered

  • Default listing returns the newest task first. Paging forward and back with limit=1 returns the same pages in the same order.
  • sortOrder=asc returns the exact reverse.
  • The same holds with free-text search (q), which uses the search SQL path.
  • /created, /assigned, /visible and /owned each return non-increasing createdAt.
  • A pre-change name cursor ({"name":"TASK-00001",…}) and sortOrder=sideways return 400, not 500.

Unit tests

  • TaskListOrderTest (new, 7 tests) covers parameter parsing, the opt-in check, first-page open bounds for both orders, the backward-page operator and direction, and rejection of name cursors.
  • FeedDAOs has no unit test. Its change is SQL that needs a real database, and the ITs below exercise it on both engines.
  • Coverage on the lines this PR changes (jacoco on the unit run plus both IT runs): 62/63 = 98.4%. TaskListOrder 46/46, FeedDAOs 9/9, TaskResource 5/5, TaskRepository 2/3. The one uncovered line is getCursorValue's name-cursor fallback, which only non-REST listings such as the search reindex reach.

Backend integration tests

  • TaskResourceIT, new: testListPagesNewestFirstBothWays, testListSearchPagesNewestFirstBothWays, testScopedListsReturnNewestFirst, testListRejectsNameCursorAndUnknownSortOrder.

Ran locally, lane parallel:

Engine Classes Result
postgres-opensearch TaskResourceIT, TaskChangeEventIT, TaskCommentsIT, TaskPermissionsIT, TaskAboutFqnChangeIT, IncidentTaskIntegrationIT, WorkflowTaskAssigneesIT, LifecycleMetadataTasksIT, EntityDeleteTaskCleanupIT, EntityCursorOffsetIT Tests run: 354, Failures: 0, Errors: 0, Skipped: 31
mysql-elasticsearch the same 10 classes Tests run: 354, Failures: 0, Errors: 0, Skipped: 31
unit (openmetadata-service) the 13 impacted classes from make java_affected Tests run: 192, Failures: 0, Errors: 0, Skipped: 0

Re-run on head 9b1d7d1 (main merged afterwards, no overlap with these files). All five ordering ITs pass on both engines (checked in the failsafe XML reports): the four new ones plus the existing testListEndpointSearchPagesBothWays.

Not run locally. make java_affected lists 71 IT classes. The remaining non-task classes (ontology, domain, glossary, table, user, …) were not run. I grepped every IT and Playwright helper that lists tasks for a first-element pick (get(0), getFirst(), findFirst(), data[0], limit=1). Every hit either filters by id/FQN first, asserts exactly one result, or reads the single open approval for an entity, so none depends on order. The incident ITs that list category=Incident&limit=100 and filter for their own task get more robust: their new task is now on the first page.

Playwright (UI) tests

  • Not applicable (no UI changes). Impacted specs were run locally against the PR server and Vite:
  • Features/AIMode/InboxTasks, Features/AIMode/InboxTaskMatrix, Features/LandingPageWidgets/LandingPageMyTasks, Features/Tasks/TaskNavigation: 42 passed, in one run with no retries.
  • Features/Glossary/GlossaryApprovalAfterMove, Features/Glossary/GlossaryAiGeneratedTerm, Features/Tasks, Pages/Tasks, Features/Tasks/TaskAllEntities, Features/EntitySuggestions, Features/DescriptionSuggestion: 76 passed.

Manual testing performed

  1. Ran the server from this branch on MySQL 8.4 + Elasticsearch 9.3 (fresh DB, migrate --force) and the UI on Vite.
  2. Created 5 tasks through the API, then listed them:
    • Default listing: newest → oldest.
    • after cursor: next page. before from page 2: back to page 1.
    • sortOrder=asc: reversed.
    • q=Smoke: newest first.
    • /created: newest first.
    • Pre-change name cursor: 400 Task list cursor 'TASK-00001' is not a creation-time cursor; list again from the first page.
    • sortOrder=sideways: 400.
  3. Created 6 tasks assigned to admin and opened Inbox → Triage. The most recent task (TASK-00011, Consolidate swagger UI and make it accessible in secure mode #6) is at the top, followed in order down to the oldest (Create teams page similar to tags #1), as in the screenshot below.

Not verified: the Postgres query plan at scale (100k+ tasks). The keyset bound is written to be sargable on the existing createdAt index, but I didn't run EXPLAIN against a large dataset.

UI screen recording:

Not applicable: a backend-only bug fix with no UI code change. Screenshot of the Triage queue on this branch, newest first:

Inbox Triage lists the newest task first

Checklist:

  • I have read the CONTRIBUTING document.

  • My PR title is Fixes <issue-number>: <short explanation>

  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.

  • I have commented on my code, particularly in hard-to-understand areas.

  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. (No schema change.)

  • For a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable). (Not applicable, see above.)

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.

  • Decision check: adds docs/decisions/2026-10-28-task-lists-page-newest-first-by-creation-time.md.

  • I have added a test that covers the exact scenario we are fixing.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues remain.

Summary

Task lists now page by createdAt and id, newest first by default.

  • Task lists now show the newest tasks first across all five endpoints.

No new actionable issues were found. The earlier scoped-test finding is fixed. As documented by yan-3005, clients holding pre-upgrade cursors must restart from the first page. Tests were not run during this review.

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

The task list endpoints (/v1/tasks, /assigned, /visible, /owned, /created)
paged by the generic (name, id) keyset, so the Inbox Triage queue and the
notification bell showed the oldest tasks first. Task names are TASK-%05d
strings compared as text, and the 2.0 migration numbered suggestions before
thread tasks, so name order is not creation order even when reversed.

The endpoints now page by a (createdAt, id) keyset, newest first, with an
optional sortOrder=asc|desc. The order is opt-in on the ListFilter, so the
search reindex keeps the name keyset its offset-seeded cursors rely on. A
name cursor issued before this change returns 400 instead of a 500.
Copilot AI balanced review requested due to automatic review settings October 28, 2026 06:15
@yan-3005
yan-3005 requested a review from a team as a code owner October 28, 2026 06:15
@yan-3005
yan-3005 requested a review from TeddyCr October 28, 2026 06:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added the safe to test Add this label to run secure Github workflows on PRs label Oct 28, 2026
testScopedListsReturnNewestFirst created unassigned tasks on an unowned
table, so /assigned and /owned could pass on empty pages. File tasks
assigned to user1 and by user1 on a user1-owned table in a fresh domain,
list each endpoint as user1 scoped to that domain, and require every
expected task on the page before checking the order.
Copilot AI balanced review requested due to automatic review settings October 28, 2026 06:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

- TaskListOrder takes the asc/desc param and derives the SQL direction;
  a previous page reuses the opposite order's operator and direction.
- @TaskListOrder.BindPage supplies operator, directions and cursor to the
  createdAt keyset queries, so each takes four parameters.
- asc/desc are defined once and reused by the endpoint annotations.
- TaskDAO only adds the createdAt branch; main's listAfter/listBefore
  branches and name-ordered search SQL are left untouched.
- Integration tests split into helpers, cursor built from a typed record.
Copilot AI balanced review requested due to automatic review settings October 28, 2026 07:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@gitar-bot

gitar-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🔴 High risk · Changing all five task endpoints to creation-time ordering rejects pre-upgrade name cursors with 400, interrupting clients paging across deployment.

Task list endpoints now page newest first by creation time using a (createdAt, id) keyset, with an optional sortOrder parameter, fixing the oldest-first ordering in Inbox Triage and the notification bell. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

@yan-3005 yan-3005 added the To release Will cherry-pick this PR into the release branch label Oct 28, 2026
@yan-3005
yan-3005 added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit af85654 Oct 28, 2026
137 checks passed
@yan-3005
yan-3005 deleted the yan-3005/collate-inc.-slack-message branch October 28, 2026 12:25
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.0 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.1 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.1 opened as #36453 (clean cherry-pick). It merges itself once the checks pass.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.0 failed. The conflict could not be resolved, so this change is not on that branch. Resolver run.

yan-3005 added a commit that referenced this pull request Oct 28, 2026
* fix(tasks): list tasks newest first by creation time

The task list endpoints (/v1/tasks, /assigned, /visible, /owned, /created)
paged by the generic (name, id) keyset, so the Inbox Triage queue and the
notification bell showed the oldest tasks first. Task names are TASK-%05d
strings compared as text, and the 2.0 migration numbered suggestions before
thread tasks, so name order is not creation order even when reversed.

The endpoints now page by a (createdAt, id) keyset, newest first, with an
optional sortOrder=asc|desc. The order is opt-in on the ListFilter, so the
search reindex keeps the name keyset its offset-seeded cursors rely on. A
name cursor issued before this change returns 400 instead of a 500.

* test(tasks): scoped list ordering checks this test's own tasks

testScopedListsReturnNewestFirst created unassigned tasks on an unowned
table, so /assigned and /owned could pass on empty pages. File tasks
assigned to user1 and by user1 on a user1-owned table in a fresh domain,
list each endpoint as user1 scoped to that domain, and require every
expected task on the page before checking the order.

* refactor(tasks): tighten task list ordering code

- TaskListOrder takes the asc/desc param and derives the SQL direction;
  a previous page reuses the opposite order's operator and direction.
- @TaskListOrder.BindPage supplies operator, directions and cursor to the
  createdAt keyset queries, so each takes four parameters.
- asc/desc are defined once and reused by the endpoint annotations.
- TaskDAO only adds the createdAt branch; main's listAfter/listBefore
  branches and name-ordered search SQL are left untouched.
- Integration tests split into helpers, cursor built from a typed record.

(cherry picked from commit af85654)

Co-authored-by: Ram Narayan Balaji <[email protected]>
harsh-vador added a commit that referenced this pull request Oct 28, 2026
The task list endpoints now page by (createdAt, id), newest first (#36395). The user Tasks tab merges its assigned and created lists with a comparator that still assumed (name, id) ascending, so it showed the oldest tasks first and held back most of each page.
alrehaili pushed a commit to alrehaili/OpenMetadata that referenced this pull request Oct 28, 2026
… and merge a user's tasks in that order (open-metadata#36439)

* fix(ui): merge a user's tasks newest first, matching the task list order

The task list endpoints now page by (createdAt, id), newest first (open-metadata#36395). The user Tasks tab merges its assigned and created lists with a comparator that still assumed (name, id) ascending, so it showed the oldest tasks first and held back most of each page.

* feat(ui): sort the task list newest or oldest first

Adds a Sort by menu (Newest first / Oldest first) beside the Inbox task
filters. The choice is sent as the list endpoints' sortOrder, so the order
holds across cursor pages, and the profile Tasks tab merges its assigned
and created sources in the same order.

* docs(decisions): record that the Inbox task list sorts only by creation time
harsh-vador added a commit that referenced this pull request Oct 29, 2026
…user's tasks in that order (#36439) (#36512)

* fix(ui): merge a user's tasks newest first, matching the task list order

The task list endpoints now page by (createdAt, id), newest first (#36395). The user Tasks tab merges its assigned and created lists with a comparator that still assumed (name, id) ascending, so it showed the oldest tasks first and held back most of each page.

* feat(ui): sort the task list newest or oldest first

Adds a Sort by menu (Newest first / Oldest first) beside the Inbox task
filters. The choice is sent as the list endpoints' sortOrder, so the order
holds across cursor pages, and the profile Tasks tab merges its assigned
and created sources in the same order.

* docs(decisions): record that the Inbox task list sorts only by creation time

(cherry picked from commit bb41b64)
@yan-3005 yan-3005 self-assigned this Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inbox Triage lists tasks oldest first: task list API pages by task name

3 participants