You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Verify that using base_url_html works correctly for all GitHub contexts (both app and user). The fix changes from dynamically extracting the URL prefix to using a predefined base_url_html property.
The condition changed from 'not any()' to 'not all()' which is a significant logical change. Verify this doesn't introduce new edge cases where some but not all parameters are present.
ifnotall([scheme_and_netloc, owner, repo]): #"else": Not invoked from a PR context,but no provided git url for contextget_logger().error(f"Unable to get canonical url parts since missing context (PR or explicit git url)")
sharoneyal
changed the title
Bugfix: Incorrect git url in case
Bugfix: Incorrect git url in case of GitHub app
Mar 25, 2025
The condition is using any() which checks if at least one element is truthy, but the logic requires all elements to be present. Using all() is correct here as we need to ensure all three variables have values.
-if not any([scheme_and_netloc, owner, repo]): #"else": Not invoked from a PR context,but no provided git url for context+if not all([scheme_and_netloc, owner, repo]): #"else": Not invoked from a PR context,but no provided git url for context
Apply this suggestion
Suggestion importance[1-10]: 10
__
Why: The PR already implements this exact change, replacing any() with all(). This is a critical fix as the original logic was incorrect - any() would return True if any element was truthy, while the function needs all elements to be present to construct a valid URL.
High
General
Correct implementation for GitHub URLs
The new implementation correctly uses self.base_url_html instead of extracting from the input URL, which fixes the issue with GitHub app URLs. This is a good fix for the bug mentioned in the PR title.
Why: The suggestion correctly identifies that using self.base_url_html is better than extracting from the input URL. This is an important fix that ensures consistent URL generation, especially for GitHub app URLs, which aligns with the PR's purpose.
Medium
More
Author self-review: I have reviewed the PR code suggestions, and addressed the relevant ones.
Add null safety checks when accessing object attributes to prevent potential runtime errors
The code doesn't check if self.base_url_html is defined before using it. This could lead to runtime errors if the attribute is None or not set. Add a null safety check to provide a fallback value when base_url_html is not available.
def get_git_repo_url(self, issues_or_pr_url: str) -> str:
repo_path = self._get_owner_and_repo_path(issues_or_pr_url) #Return: <OWNER>/<REPO>
if not repo_path or repo_path not in issues_or_pr_url:
get_logger().error(f"Unable to retrieve owner/path from url: {issues_or_pr_url}")
return ""
- return f"{self.base_url_html}/{repo_path}.git" #https://github.com / <OWNER>/<REPO>.git+ base_url = getattr(self, 'base_url_html', '')+ if not base_url:+ get_logger().error("base_url_html is not defined")+ return ""+ return f"{base_url}/{repo_path}.git" #https://github.com / <OWNER>/<REPO>.git
Suggestion importance[1-10]: 6
Low
General
Clarify condition comment
The comment is misleading. This condition checks if any required component is missing, not specifically about PR context. Consider updating the comment to accurately reflect the logic.
-if not all([scheme_and_netloc, owner, repo]): #"else": Not invoked from a PR context,but no provided git url for context+if not all([scheme_and_netloc, owner, repo]): #Check if any required URL component is missing
Suggestion importance[1-10]: 3
__
Why: The suggestion correctly identifies that the comment is misleading and doesn't accurately reflect the condition's purpose. The improved comment better explains that the condition checks for missing URL components, which enhances code readability and maintainability.
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
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.
User description
Fix incorrect parsing when PR/issue url is from Github app context, so: https://api.github.com/repos/Codium-ai/pr-agent/issues/123 would have generated the incorrect git repo: https://api.github.com/repos/Codium-ai/pr-agent.git instead of https://github.com/Codium-ai/pr-agent.git
PR Type
Bug fix
Description
Fix incorrect Git URL generation for GitHub app context.
Ensure consistent URL formatting for both user and app contexts.
Improve error handling for invalid or missing URL components.
Changes walkthrough 📝
github_provider.py
Fix Git URL generation and error handlingpr_agent/git_providers/github_provider.py
base_url_html.