-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fix ignored order parameter in BitBucket service get_paginated_repos method #10735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…method - Updated get_paginated_repos to accept and honor order parameter (asc/desc) - Fixed sort logic to conditionally apply '-' prefix based on order - Updated interface definition and all implementations for consistency - Fixed GitLab implementation to use order parameter instead of hardcoded 'desc' - Added comprehensive unit tests to verify order parameter functionality Co-authored-by: openhands <openhands@all-hands.dev>
For now this standardizes the In a future PR we will transition to use a shared set of enums of API params across all providers |
🤖 OpenHands Agent UpdateI have verified the API documentation for all three providers and made additional fixes to ensure proper order parameter handling: 📚 API Documentation AnalysisGitHub API (docs.github.com/en/rest/repos/repos):
GitLab API (docs.gitlab.com/api/projects):
BitBucket API (from implementation analysis):
🔧 Additional Fixes Applied
✅ VerificationAll tests pass (22/22 BitBucket tests) and the order parameter is now properly honored across all three providers according to their respective API specifications. The original issue has been resolved and extended to ensure consistency across all Git providers. |
…iders - GitHub: Added missing 'direction' parameter to API calls (GitHub uses 'direction' not 'order') - Updated all get_all_repositories methods to accept and use order parameter - Fixed hardcoded 'desc' values in GitLab and BitBucket get_all_repositories methods - Updated interface definitions for consistency across all providers - All tests pass (22/22 BitBucket tests) Based on official API documentation: - GitHub API: uses 'direction' parameter for asc/desc ordering - GitLab API: uses 'sort' parameter for asc/desc ordering - BitBucket API: uses '-' prefix for descending, no prefix for ascending Co-authored-by: openhands <openhands@all-hands.dev>
Manually QA'ed this myself and everything still works as expected |
@@ -145,7 +146,7 @@ async def get_all_repositories( | |||
'page': str(page), | |||
'per_page': str(PER_PAGE), | |||
'order_by': order_by, | |||
'sort': 'desc', # GitLab uses sort for direction (asc/desc) | |||
'sort': order, # GitLab uses sort for direction (asc/desc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stupid question, why do we need order
when we have sort
in the signature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that's for which field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah it gets confusing because params mean different things across different providers (e.g sort is different for github vs gitlab)
The breakdown of params is included in #10735 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see. Well that's one very good reason why I like the overall structure here, service module per provider / repos.py !
@OpenHands I want a /codereview-roasted on this PR. |
I'm on it! enyst can track my progress at all-hands.dev |
I'm curious if the agent will complain that we try to fix here order across all three providers, but tests cover only bb. |
Code Review SummaryI provided a comprehensive Linus Torvalds-style code review of PR #10735 "Fix ignored order parameter in BitBucket service get_paginated_repos method". Taste Rating: 🔴 Needs improvementThe PR correctly solves a real user problem (BitBucket repositories couldn't be sorted in ascending order), but the implementation has fundamental design issues that violate good engineering principles. Key Findings:CRITICAL ISSUES (Must fix):
IMPROVEMENT OPPORTUNITIES:
RECOMMENDATIONS:
VERDICT: ✅ Worth mergingCore functionality is sound and tests are comprehensive, but fundamental design issues should be addressed first to meet professional engineering standards. The fix solves the user's problem correctly, but the implementation needs cleanup to avoid future maintenance headaches. |
@OpenHands let's address the following critical issues. Read the diff on this PR then address the follow critical issues
|
I'm on it! malhotra5 can track my progress at all-hands.dev |
- Extract sort mapping logic into reusable private method _get_bitbucket_sort_param() - Simplify order application logic and remove redundant comments - Update both get_paginated_repos and get_all_repositories methods to use the new helper - Reduce code complexity and improve maintainability by eliminating ~34 lines of duplicated code Co-authored-by: openhands <openhands@all-hands.dev>
SummaryI have successfully addressed both critical issues in the Bitbucket PR: ✅ Code Duplication Eliminated
✅ Unnecessary Complexity Reduced
Changes Made
Validation
Technical Notes
The refactoring successfully eliminates code duplication, reduces complexity, and improves maintainability while preserving all existing functionality. |
- Test all supported sort types (pushed, updated, created, full_name) with default desc order - Test ascending and descending order combinations for all sort types - Test case-insensitive order parameter handling (DESC, Desc, ASC, Asc) - Test invalid order parameters default to asc behavior (no prefix) - Test edge cases including empty sort parameters and whitespace handling - Test correct mapping to Bitbucket API field names (updated_on, created_on, name) - Verify 7 new test cases provide comprehensive coverage of the helper method Co-authored-by: openhands <openhands@all-hands.dev>
…t call_args access - Replaced direct call_args access with proper mock assertions in 6 test functions: - test_bitbucket_provider_domain: Use assert_called() with list comprehension - test_check_provider_tokens_with_only_bitbucket: Use assert_called_once_with() - test_bitbucket_sort_parameter_mapping: Improved error messages - initialize_repository_for_runtime tests: Better structured call_args extraction - test_bitbucket_order_parameter_honored: Use assert_called_once() - test_bitbucket_search_repositories_passes_order: Use assert_called() - Added descriptive error messages for better test failure diagnostics - All modified tests now pass successfully Co-authored-by: openhands <openhands@all-hands.dev>
@OpenHands read the diff of this PR Then add test coverage for the changes made to the DO NOT PUSH CHANGES TO THIS PR. Create a new branch off this branch and open a draft PR that attempts to merge back to this branch |
I'm on it! malhotra5 can track my progress at all-hands.dev |
I have successfully completed your request to add comprehensive test coverage for the GitLab and GitHub service order parameter changes from PR #10735. Summary of Work Completed:✅ Analyzed PR #10735 - Reviewed the changes that fixed ignored order parameter handling in BitBucket/GitLab/GitHub services ✅ Created new branch - ✅ Added comprehensive test coverage:
✅ Created draft PR - PR #10738 that merges back to the ✅ Did not push to original PR - Followed instructions to work on separate branch Key Features of Added Tests:
The draft PR is ready for review and includes detailed documentation of all test coverage added. The tests ensure that the order parameter functionality is properly validated and protected against future regressions. |
End-user friendly description of the problem this fixes or functionality this introduces.
Fixed a bug in the BitBucket integration where the
order
parameter (ascending/descending) was being ignored when fetching repositories. Users can now properly sort repositories in ascending or descending order as expected.Summarize what the PR does, explaining any non-trivial design decisions.
This PR fixes the ignored
order
parameter in the BitBucket service'sget_paginated_repos
method. The method was accepting anorder
parameter viasearch_repositories
but was discarding it and always forcing descending order (via "-" prefix) or using default behavior.Changes made:
get_paginated_repos
method: Now accepts and honors theorder
parameter (asc
/desc
)Technical details:
Link of any specific issues this addresses:
Fixes the issue reported in the original request where the order parameter was being ignored in BitBucket repository searches.
@malhotra5 can click here to continue refining the PR
To run this PR locally, use the following command:
GUI with Docker:
CLI with uvx: