bugfix: fix chatmessage pagination for standard queries#6301
Open
AnwarRezk wants to merge 5 commits intoFlowiseAI:mainfrom
Open
bugfix: fix chatmessage pagination for standard queries#6301AnwarRezk wants to merge 5 commits intoFlowiseAI:mainfrom
AnwarRezk wants to merge 5 commits intoFlowiseAI:mainfrom
Conversation
Apply page and limit to the default chat message query path so paginated requests no longer return the full dataset. Add regression coverage for paginated and unpaginated retrieval.
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements pagination for the utilGetChatMessage function by adding skip and take parameters to the database query. It also includes unit tests to verify that pagination is correctly applied when page and pageSize are provided and ignored when they are not. I have no feedback to provide.
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
pageandlimitto the defaultGET /api/v1/chatmessage/:idquery pathProblem
GET /api/v1/chatmessage/:idwas already accepting pagination parameters, but the standardChatMessage.find(...)path inutilGetChatMessagedid not apply them.As a result, requests such as:
/api/v1/chatmessage/:id?page=2&limit=100could return the same full message set as page 1 instead of the requested slice.
Root Cause
In
packages/server/src/utils/getChatMessage.ts, the non-feedback query path passed filters and ordering to TypeORM, but did not setskip/take.Fix
skipandtaketo the default query when bothpageandpageSizeare validTesting
packages/server/src/utils/getChatMessage.test.tsskipandtakeRelated Issues