fix(webhooks): correct keyset cursor lookup for table-qualified columns - #978
Open
rexx010 wants to merge 1 commit into
Open
fix(webhooks): correct keyset cursor lookup for table-qualified columns#978rexx010 wants to merge 1 commit into
rexx010 wants to merge 1 commit into
Conversation
…lookup
applyKnexKeyset() looked up cursor values by the raw column name
(e.g. "e.created_at") but cursors are encoded with plain field
names ("created_at"), so keyset comparisons bound to undefined
and page 2+ silently came back empty.
🤖 Greptile AI Code ReviewGreptile will automatically review this PR (2 file(s) changed). Review gates:
|
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.
applyKnexKeyset() looked up cursor values by the raw column name (e.g. "e.created_at") but cursors are encoded with plain field names ("created_at"), so keyset comparisons bound to undefined and page 2+ silently came back empty.
Summary
Fixes
applyKnexKeysetso table-qualified sort columns (e.g. "e.created_at") correctly resolve against cursor objects, which are always keyed by plain field names — restoring working pagination past page 1 for the webhook events endpoint.Type of change
Related issue
Closes #888
Changes
backend/src/utils/paginate.js:applyKnexKeysetnow strips a table-alias prefix before reading the cursor object, and skips the seek predicate entirely if the cursor is missing a required field instead of comparing a column toundefined.backend/__tests__/webhookService.test.js: fixed the knex mock'sjoin()to actually evaluatewhere/andWhere/orWherecallbacks and sort rows viaorderBy(it previously no-op'd them, so it couldn't exercise real keyset behavior).created_atevents return every row exactly once (no overlap, no gap).Testing
npx jest __tests__/webhookService.test.js→ 23/23 passnpx eslint src/utils/paginate.js→ cleanScreenshots (if UI change)
N/A — backend-only fix, no UI change.
Checklist
main