Page MenuHomePhorge

Fix "Map omits required key" exception by comparing result order against modern field keys
ClosedPublic

Authored by aklapper on Jan 4 2024, 09:17.

Details

Summary

Sorting a Maniphest search query by custom fields throws a "Map returned omits required key" exception.

The isCustomFieldOrderKey() check still tested against legacy field key format (for example [custom:]std:maniphest:deadline.due) while the code passes modern field key format (for example custom.deadline.due).

After fixing this, PhutilTypeSpec::checkMap() throws an exception when a non-optional (extra) key $column is in $columns but not in the array of type parameters below to check against:
"Got unexpected parameters: customfield, customfield.index.table, customfield.index.key"
Thus add optional types for customfields in buildPagingClauseFromMultipleColumns() to allow them instead of throwing another exception.

Closes T15631

Test Plan

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.Jan 4 2024, 09:17

lgtm

Thanks \o/ Can reproduce.

I tried all Order By fields in Maniphest, with and without ?after= and finally no crash with ?after=1 or anything. Tried also Differential and still works.

I think nobody noticed because usually people rarely go to the second page of their search engine in Phorge. I mean, Phorge shows 100 (!) results in the first page. That is up to 5~ times more stuff on first page compared than other popular applications. For instance in GitLab I'm always hitting the next page since it shows just 20 elements. Same with GitHub. Still, though, it amazes me that there is no bug in secure.dot on this.

This revision is now accepted and ready to land.Mar 10 2024, 16:41