-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Allow PORT override for GitLab webhook server #2157
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?
Allow PORT override for GitLab webhook server #2157
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
|
/help |
Qodo Merge Walkthrough 🤖Welcome to Qodo Merge, an AI-powered tool for automated pull request analysis, feedback, suggestions and more. Here is a list of tools you can use to interact with Qodo Merge:
(1) Note that each tool can be triggered automatically when a new PR is opened, or called manually by commenting on a PR. (2) Tools marked with [*] require additional parameters to be passed. For example, to invoke the |
|
/ask could you check the pr and let me know if there is other change I could do make it merge |
Ask❓could you check the pr and let me know if there is other change I could do make it merge Answer:Great work on this PR! The implementation is solid and well-tested. Here are some suggestions to make it merge-ready: Code Quality Improvements
def start():
try:
port = int(os.environ.get("PORT", "3000"))
if os.environ.get("PORT"):
get_logger().info(f"Using custom PORT from environment: {port}")
except ValueError:
get_logger().warning("Invalid PORT environment variable, using default port 3000")
port = 3000
uvicorn.run(app, host="0.0.0.0", port=port)
try:
port = int(os.environ.get("PORT", "3000"))
if not (1 <= port <= 65535):
raise ValueError(f"Port {port} is out of valid range")
except ValueError as e:
get_logger().warning(f"Invalid PORT environment variable ({e}), using default port 3000")
port = 3000Test Improvements
def test_start_default_port(monkeypatch):
monkeypatch.setenv("GITLAB__URL", "https://gitlab.example.com")
monkeypatch.delenv("PORT", raising=False)
module = _load_module()
with mock.patch.object(module.uvicorn, "run") as mock_run:
module.start()
_, kwargs = mock_run.call_args
assert kwargs["port"] == 3000
Documentation
def start():
"""
Start the GitLab webhook server.
The server port can be configured via the PORT environment variable.
Defaults to 3000 if PORT is not set or invalid.
"""Minor Fixes
Overall, this is a clean and focused PR. The main suggestions are around robustness (port validation), observability (logging), and completeness (additional test cases). These are optional improvements - the current implementation is functional and ready for review! |
|
/review |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Final update:
Note: |
User description
Summary
Testing
PR Type
Enhancement, Tests
Description
Allow PORT environment variable override for GitLab webhook server
Default port remains 3000 if PORT env var not set
Add unit test verifying PORT override functionality
Diagram Walkthrough
File Walkthrough
gitlab_webhook.py
Add PORT environment variable supportpr_agent/servers/gitlab_webhook.py
osmodule for environment variable accessstart()function to read PORT from environmentuvicorn.run()test_gitlab_webhook_port.py
Unit test for PORT environment overridetests/unittest/test_gitlab_webhook_port.py