-
Notifications
You must be signed in to change notification settings - Fork 625
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
Add Support GitHub Enterprise Server URL pattern #1270
Conversation
- Update _parse_pr_url and _parse_issue_url functions to use regex - Improve handling of various GitHub URL formats, including Enterprise Server - Simplify logic and reduce code duplication - Enhance error handling for invalid URL structures
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Code Suggestions ✨Explore these optional code suggestions:
|
Hi @yamao-latte As this PR changes a critical component, the level of tests and code quality needed to approve this PR is high. As a general rule of thumb, as few changes as possible is the best way to go. I will also give code comments, but comprehensive tests, to ensure that compatibility to the GitHub cloud remains, are a must for this PR be considered to merge. |
if self.base_url.endswith("/api/v3"): | ||
# enterprise server with api/v3 | ||
self.base_url_html = self.base_url[:len("/api/v3")] | ||
elif self.base_url == "https://api.github.com": | ||
# github cloud | ||
self.base_url_html = "https://github.com" | ||
else: | ||
self.base_url_html = self.base_url |
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.
explain this change.
why is it needed ?
Give concrete examples - what didn't work before, and is working now due to this change ?
repo_name = '/'.join(path_parts[1:3]) | ||
path = parsed_url.path | ||
|
||
pattern = r'/repos/([^/]+/[^/]+)/issues/(\d+)' |
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.
would this format support:
https://github.com/Codium-ai/pr-agent/issues/1268
for example
?
if len(path_parts) < 5 or path_parts[3] != 'pulls': | ||
raise ValueError("The provided URL does not appear to be a GitHub PR URL") | ||
repo_name = '/'.join(path_parts[1:3]) | ||
pattern = r'/repos/([^/]+/[^/]+)/pulls?/(\d+)' |
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.
would this format support
https://github.com/Codium-ai/pr-agent/pull/1270
for example ?
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.
We would like to support a format such as:
https://github.enterprise-server.com/api/v3/repos/Codium-ai/pr-agent/pull/1270
In GitHub Enterprise Server, the API URLs include the api/v3
segment. The current implementation uses a hard-coded check:
if len(path_parts) < 5 or path_parts[3] != 'pulls':
This approach does not account for the api/v3
part of the URL, leading to errors when the URL structure differs. Specifically, this issue affects the following part of the code:
For more information on the URL structure, refer to the GitHub Enterprise Server documentation:
GitHub Docs - Get a Pull Request
pr-agent/pr_agent/servers/github_action_runner.py
Lines 91 to 115 in ada0a3d
pr_url = event_payload.get("pull_request", {}).get("url") | |
if pr_url: | |
# legacy - supporting both GITHUB_ACTION and GITHUB_ACTION_CONFIG | |
auto_review = get_setting_or_env("GITHUB_ACTION.AUTO_REVIEW", None) | |
if auto_review is None: | |
auto_review = get_setting_or_env("GITHUB_ACTION_CONFIG.AUTO_REVIEW", None) | |
auto_describe = get_setting_or_env("GITHUB_ACTION.AUTO_DESCRIBE", None) | |
if auto_describe is None: | |
auto_describe = get_setting_or_env("GITHUB_ACTION_CONFIG.AUTO_DESCRIBE", None) | |
auto_improve = get_setting_or_env("GITHUB_ACTION.AUTO_IMPROVE", None) | |
if auto_improve is None: | |
auto_improve = get_setting_or_env("GITHUB_ACTION_CONFIG.AUTO_IMPROVE", None) | |
# Set the configuration for auto actions | |
get_settings().config.is_auto_command = True # Set the flag to indicate that the command is auto | |
get_settings().pr_description.final_update_message = False # No final update message when auto_describe is enabled | |
get_logger().info(f"Running auto actions: auto_describe={auto_describe}, auto_review={auto_review}, auto_improve={auto_improve}") | |
# invoke by default all three tools | |
if auto_describe is None or is_true(auto_describe): | |
await PRDescription(pr_url).run() | |
if auto_review is None or is_true(auto_review): | |
await PRReviewer(pr_url).run() | |
if auto_improve is None or is_true(auto_improve): | |
await PRCodeSuggestions(pr_url).run() |
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.
if this PR won't provide complete and total support also for regular github, it cannot be merged.
All the issues I stated above should be addressed and fixed.
For example, currently
https://github.com/Codium-ai/pr-agent/pull/1266
(CLI)
is not supported in this new code . it was supported before
@yamao-latte You can still utilize the code in your local deployment |
anyway, github serve support was added here you are welcome to try it and give feedback |
User description
Closes #1268
Description
When the provider is set to 'github', the current implementation fails to correctly parse URLs from GitHub Enterprise Server instances. This causes errors when users attempt to use Enterprise Server URLs with our system.
Current Behavior
Expected Behavior
Steps to Reproduce
Proposed Solution
Update the URL parsing logic to accommodate both github.com and GitHub Enterprise Server URL structures. This may involve:
Additional Notes
This issue is related to the recent changes made in the PR and issue URL parsing functions. While those changes improved the situation, they didn't fully address the Enterprise Server use case.
PR Type
Enhancement
Description
Changes walkthrough 📝
github_provider.py
Enhance GitHub URL parsing and compatibility
pr_agent/git_providers/github_provider.py
issues
compatibility