Repository navigation
Resolve next page cursor loop - #188
Closed
Nidhi091999 wants to merge 5 commits into
Closed
Nidhi091999 wants to merge 5 commits into
Nidhi091999 wants to merge 5 commits into
Conversation
Reviewer's GuideAdjusts pagination logic to prevent infinite loops by fetching an extra record and refactors the exceptions module by reordering definitions, introducing new error classes (InputUriError, IPDistanceCalculationError, TesUriError), and updating the error mapping. Class diagram for updated exception classesclassDiagram
class InputUriError {
<<ValueError>>
}
class IPDistanceCalculationError {
<<ValueError>>
}
class TesUriError {
<<ValueError>>
}
class NoTesInstancesAvailable {
<<ValueError>>
}
class TaskNotFound {
<<NotFound>>
}
class IdsUnavailableProblem {
<<PyMongoError>>
}
class MiddlewareException {
<<ValueError>>
}
class InvalidMiddleware {
<<MiddlewareException>>
}
InputUriError --|> ValueError
IPDistanceCalculationError --|> ValueError
TesUriError --|> ValueError
NoTesInstancesAvailable --|> ValueError
TaskNotFound --|> NotFound
IdsUnavailableProblem --|> PyMongoError
InvalidMiddleware --|> MiddlewareException
MiddlewareException --|> ValueError
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @Nidhi091999 - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `pro_tes/ga4gh/tes/task_runs.py:297` </location>
<code_context>
logger.debug(f"Tasks list: {tasks_list}")
- if tasks_list:
- next_page_token = str(tasks_list[-1]["_id"])
+ if len(tasks_list) > page_size:
+ next_page_token = str(tasks_list[page_size-1]["_id"])
+ tasks_list = tasks_list[:page_size]
else:
</code_context>
<issue_to_address>
The logic for next_page_token may skip the correct item if page_size is 0.
Accessing tasks_list[page_size-1] when page_size is 0 retrieves the last element, which is likely unintended. Please add a check for page_size == 0 to prevent this issue.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Comment on lines
+297
to
+298
| if len(tasks_list) > page_size: | ||
| next_page_token = str(tasks_list[page_size-1]["_id"]) |
There was a problem hiding this comment.
issue (bug_risk): The logic for next_page_token may skip the correct item if page_size is 0.
Accessing tasks_list[page_size-1] when page_size is 0 retrieves the last element, which is likely unintended. Please add a check for page_size == 0 to prevent this issue.
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.
Fix(pagination): resolve next page cursor loop
Summary by Sourcery
Resolve infinite pagination loop and extend error handling
Bug Fixes:
Enhancements: