fix(data): sweep non-canonical sort key direction: → SortNode's order: (desc silently sorted ascending)#1772
Merged
Merged
Conversation
…g — sweep to SortNode's order: SortNode (spec/data/query.zod.ts) takes `order: 'asc'|'desc'` (default asc); Zod strips an unknown `direction:` key, so every desc sort using it silently returned ascending. Same bug class fixed in plugin-approvals via #1769. Behavior-changing (desc was silently asc): - plugin-reports listReports: most-recently-updated first - plugin-sharing listShares: newest grant first - service-job listExecutionsByStatus: "latest run" actually returned the OLDEST run - service-queue listFailed: newest message first Cosmetic (asc default made behavior accidentally right, key still wrong): - plugin-reports listSchedules, plugin-sharing listRules, share-link-routes messages sort, service-queue claimBatch Doc/template sites (schema-verified): - cli explain: query example sort key — FindOptions.sort takes SortNode[] - cli generate + spec benchmark: list-view template used a phantom `defaultSort:` key (ListViewSchema only has `sort: [{field, order}]`); benchmark validQuery used `sort:` which QuerySchema doesn't have → orderBy Left alone: plugin-auth objectql-adapter (better-auth's own sortBy.direction, already translated to {field, order}); graphql.zod.ts defaultSort (a separate schema that legitimately uses direction: 'ASC'|'DESC'). Tests: all four fake-engine mocks now honor ONLY the canonical `order` key (honoring both is how the approvals bug stayed hidden), plus a descending- order regression test per package; mutation-checked that reverting the service-job fix fails its new test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
SortNode(packages/spec/src/data/query.zod.ts) takesorder: 'asc'|'desc'with defaultasc. Zod strips the unknowndirection:key, so every engine query sorting withdirection: 'desc'silently sorted ascending. Same bug class as the plugin-approvals fix that landed in #1769; this sweeps the remaining sites.Behavior-changing (desc was silently asc)
listReports— now genuinely most-recently-updated firstlistShares— newest grant firstlistExecutionsByStatus— "latest run" was returning the oldest runlistFailed— newest DLQ message firstCosmetic (asc default made behavior accidentally right, key still wrong)
plugin-reports
listSchedules, plugin-sharinglistRules+ share-link messages sort, service-queueclaimBatch(×2).Doc/template sites (schema-verified before changing)
cli explainquery example — engineFindOptions.sortvalidates againstSortNode[]cli generatelist-view template + spec benchmark — used a phantomdefaultSort:key (ListViewSchemaonly hassort: [{field, order}], view.zod.ts:422); benchmarkvalidQueryusedsort:whichQuerySchemadoesn't have →orderByVerified-correct, left alone
sortBy.directionis better-auth's own interface, already translated to canonical{field, order}at both sitesdefaultSort— separate schema that legitimately usesdirection: 'ASC'|'DESC'Tests
orderkey, with a comment explaining why (mocks honoring both keys is exactly how the approvals bug stayed hidden)tsc --noEmitclean on spec🤖 Generated with Claude Code