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.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 9, 09:27
Unknown Object (File)
Wed, May 8, 07:11
Unknown Object (File)
Sun, May 5, 23:27
Unknown Object (File)
Sun, May 5, 23:27
Unknown Object (File)
Sun, May 5, 23:26
Unknown Object (File)
Sun, May 5, 07:20
Unknown Object (File)
Fri, May 3, 01:12
Unknown Object (File)
Wed, Apr 24, 22:23

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
Branch
T15631customFiledMapQuery (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 1001
Build 1001: arc lint + arc unit

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