fix(data-objectstack): a string $orderby reaches the server as a sort, not a list of character indices (#3106) - #3109
Merged
Conversation
…rt, not a list of character indices (#3106) `QueryParams['$orderby']` declares four shapes — `string`, `string[]`, `SortNode[]`, `Record<field, direction>`. Both `find()` routes carried their own copy of the fold that serializes it (`convertQueryParams` for a plain read, `rawFindWithPopulate` for one carrying `$expand`/`$search`), and both copies handled the same three. The bare string fell through to the `Record` branch, where `Object.entries('name asc')` enumerates the string's character indices — so the request went out as `sort=0,1,2,3,4,5,6,7`. Since objectstack#4226 the server refuses a sort it cannot read (`400 INVALID_SORT`) rather than dropping it, so this was not a degraded ordering but a list that failed to load outright. `"${field} ${order}"` is exactly what `ObjectGrid` builds from its view metadata's `sort`, which made every standalone grid with a configured sort a broken one. One exported `serializeOrderBy` now backs both routes, for the same reason the filter path already shares one: two copies of a fold can only agree by inspection, and these two did not. The new suite runs every declared shape down both routes and asserts they agree. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
This was referenced Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
QueryParams['$orderby']declares four shapes —string,string[],SortNode[],Record<field, direction>. Bothfind()routes carried their own copy of the fold that serializes it, and both copies handled the same three of them.The bare string fell through to the
Recordbranch, whereObject.entries('name asc')enumerates the string's character indices:(That URL is copied from a test run against the pre-fix code, not constructed by hand.)
Why it matters
Since objectstack#4226 the server refuses a sort it cannot read (
400 INVALID_SORT) rather than dropping it silently. So this was never a degraded ordering — it was a list that failed to load outright.`${field} ${order}`is exactly whatObjectGridbuilds from its view metadata'ssort(ObjectGrid.tsx:536-547), so every standaloneObjectGridwith a configured sort was broken. The ListView path sends the array form and was unaffected, which is why this survived: the two callers disagreed about the shape and only one of them was ever exercised.How
One exported
serializeOrderBynow backs both routes — the same consolidation the filter path already has, and for the same reason (#3713's "two readers of one contract"): two copies of a fold can only agree by inspection, and these two did not.Tests
orderby-serialization.test.tsruns every declared shape down both routes and asserts they agree — 27 cases. Verified they fail against the pre-fix code (that is where thesort=0,1,2…above comes from).Net typecheck effect is negative-error: the two
TS7006implicit-anyerrors in the deleted folds are gone.Scope
Found while scoping #3106 (column-header sort under server pagination). Independent of that fix and landing first — it is broken on
maintoday, with or without #3106.🤖 Generated with Claude Code