Skip to content

fix(ui-next): sort Agent Name on the column that is actually indexed - #1516

Closed
manan164 wants to merge 1 commit into
mainfrom
fix/agent-executions-sort-agent-name
Closed

fix(ui-next): sort Agent Name on the column that is actually indexed#1516
manan164 wants to merge 1 commit into
mainfrom
fix/agent-executions-sort-agent-name

Conversation

@manan164

@manan164 manan164 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #1514

handleSort was renaming the column id workflowType to workflowName before sending it. workflowName isn't a real field on any backend — not in the sqlite/postgres VALID_FIELDS, not in the ES mappings — so the sort was dropped and rows came back in whatever order the query plan yielded. On Elasticsearch it's worse: the unmapped field is rejected outright and the search returns HTTP 500, so the page fails to load rather than mis-ordering. This PR deletes that rename; the column id now goes through unchanged. The same bad remap existed on the workflow executions and task search pages, so all five call sites now share one helper.

Before — clicking the name column sends workflowName:DESC → 500, table empty

before

After — sends workflowType:DESC → 200, rows sorted

after

Same URL, same filters, same server; only the handleSort line differs. (Captured on the Workflow Executions page, which shares the identical remap — the environment had no agent executions to show.)

Frontend-only, no backend behaviour change. Tests added at both layers (buildSortParam, sqlite + postgres query builders), each confirmed failing before the fix.

Not addressed here: workflow_type is non-unique and no tiebreaker is appended, so rows sharing an agent name can still shuffle across page boundaries under offset paging.

@manan164
manan164 marked this pull request as draft August 10, 2026 14:13
@manan164
manan164 force-pushed the fix/agent-executions-sort-agent-name branch from 44e651f to dea8db4 Compare August 10, 2026 15:04
Clicking the Agent Name header on the agent executions page sent
`sort=workflowName:ASC`, because handleSort renamed the column id
`workflowType` to `workflowName` on the way out.

The index query builders snake_case the sort field and match it against
an allow-list of real columns. `workflow_name` is not one of them --
`workflow_type` is -- so getSort() matched nothing and returned "",
emitting no ORDER BY at all. The query became a bare
`SELECT json_data FROM workflow_index [WHERE ...] LIMIT ? OFFSET ?`,
so row order was whatever the query plan happened to yield: table-scan
order with no filters, index order once a status filter narrowed it.
That is why the sort looked like it worked sometimes and not others,
and why ASC and DESC could return identical rows.

Nothing surfaced the mismatch, since an unrecognised sort field is
dropped silently rather than rejected.

Drop the rename and send the column id through unchanged. The same
remap existed on the workflow executions and task search pages, which
sort the same `workflow_type` column; all five call sites now share one
helper so the mapping is stated once and covered by a test.

Also pin the backend contract the UI violated. The sqlite and postgres
query builder tests now assert that `workflowType:ASC` produces
`ORDER BY workflow_type ASC`, and that an unindexed field such as
`workflowName` produces no ORDER BY.

Fixes #1514
@manan164
manan164 force-pushed the fix/agent-executions-sort-agent-name branch from dea8db4 to ddf660a Compare August 10, 2026 15:33
@manan164

Copy link
Copy Markdown
Contributor Author

Closing this since #1515 takes care of this.

@manan164 manan164 closed this Aug 10, 2026
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.

Sorting the agent name in ascending and descending order does not work reliably - this is on the agent executions page

1 participant