From d8812c409531b71fcc3514af1def5578a3705a9a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 28 Jul 2025 16:19:55 +0000 Subject: [PATCH 1/4] Initial plan From 3b24d826cfbd58ca5c1a8333f2a899bcdd0538d8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 28 Jul 2025 16:33:05 +0000 Subject: [PATCH 2/4] Fix gunicorn upgrade compatibility issue in test Co-authored-by: pamelafox <297042+pamelafox@users.noreply.github.com> --- src/gunicorn_test.py | 5 +++-- src/requirements.txt | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gunicorn_test.py b/src/gunicorn_test.py index e452352..e276b94 100644 --- a/src/gunicorn_test.py +++ b/src/gunicorn_test.py @@ -2,7 +2,7 @@ from unittest import mock import pytest -from gunicorn.app.wsgiapp import run +from gunicorn.app.wsgiapp import WSGIApplication def test_config_imports(): @@ -10,6 +10,7 @@ def test_config_imports(): with mock.patch.object(sys, "argv", argv): with pytest.raises(SystemExit) as excinfo: - run() + app = WSGIApplication() + app.run() assert excinfo.value.args[0] == 0 diff --git a/src/requirements.txt b/src/requirements.txt index f3d5b9e..e6ce857 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -1,3 +1,3 @@ fastapi==0.111.0 uvicorn[standard]==0.29.0 -gunicorn==22.0.0 +gunicorn==23.0.0 From a64491ca61ce9f6fbfdfc4e9326dfd289db0aa70 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 28 Jul 2025 16:36:09 +0000 Subject: [PATCH 3/4] Add installation verification script for gunicorn upgrade Co-authored-by: pamelafox <297042+pamelafox@users.noreply.github.com> --- verify_installation.py | 90 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100755 verify_installation.py diff --git a/verify_installation.py b/verify_installation.py new file mode 100755 index 0000000..fa0f862 --- /dev/null +++ b/verify_installation.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 +""" +Verification script for the gunicorn upgrade fix. +This script verifies that the upgraded dependencies can be installed and work correctly. +""" + +import sys +import subprocess +import os + +def run_command(cmd, description): + """Run a command and return True if successful.""" + print(f"\nšŸ” {description}") + print(f"Running: {cmd}") + try: + # Use bash explicitly for source command + if 'source' in cmd: + cmd = f"bash -c '{cmd}'" + result = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True) + print(f"āœ… Success: {description}") + if result.stdout: + print(f"Output: {result.stdout}") + return True + except subprocess.CalledProcessError as e: + print(f"āŒ Failed: {description}") + print(f"Error: {e.stderr}") + return False + +def main(): + """Main verification function.""" + print("šŸš€ Starting installation verification for gunicorn upgrade fix...") + + # Change to the repository directory + repo_dir = os.path.dirname(os.path.abspath(__file__)) + os.chdir(repo_dir) + print(f"Working directory: {repo_dir}") + + success = True + + # Create a virtual environment + if not run_command("python3 -m venv .venv_verify", "Creating verification virtual environment"): + return False + + # Install requirements-dev.txt (which includes src/requirements.txt) + if not run_command("source .venv_verify/bin/activate && pip install --upgrade pip", "Upgrading pip"): + success = False + + if not run_command("source .venv_verify/bin/activate && pip install -r requirements-dev.txt", "Installing dev requirements"): + success = False + + # Check that gunicorn installed correctly + if not run_command("source .venv_verify/bin/activate && python -c 'import gunicorn; print(f\"Gunicorn version: {gunicorn.__version__}\")'", "Checking gunicorn installation"): + success = False + + # Run the tests + if not run_command("source .venv_verify/bin/activate && python -m pytest src/gunicorn_test.py -v", "Running gunicorn test"): + success = False + + # Run all tests + if not run_command("source .venv_verify/bin/activate && python -m pytest -v", "Running all tests"): + success = False + + # Test the FastAPI application can start + if not run_command("source .venv_verify/bin/activate && python -c 'from src.api.main import app; print(\"āœ… FastAPI app imports correctly\")'", "Testing FastAPI app import"): + success = False + + # Test gunicorn configuration check + if not run_command("source .venv_verify/bin/activate && cd src && gunicorn --check-config api.main:app", "Testing gunicorn config check"): + success = False + + # Cleanup + run_command("rm -rf .venv_verify", "Cleaning up verification environment") + + if success: + print("\nšŸŽ‰ All verification tests passed!") + print("The gunicorn upgrade fix is working correctly.") + print("\nTo install and verify manually:") + print("1. python3 -m venv .venv") + print("2. source .venv/bin/activate") + print("3. pip install -r requirements-dev.txt") + print("4. python -m pytest") + return True + else: + print("\nāŒ Some verification tests failed.") + print("Please check the error messages above.") + return False + +if __name__ == "__main__": + success = main() + sys.exit(0 if success else 1) \ No newline at end of file From f2835498a97022fd6bd4c195f2ab4d42c5199563 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 28 Jul 2025 16:37:21 +0000 Subject: [PATCH 4/4] Add comprehensive documentation for gunicorn upgrade fix Co-authored-by: pamelafox <297042+pamelafox@users.noreply.github.com> --- UPGRADE_NOTES.md | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 UPGRADE_NOTES.md diff --git a/UPGRADE_NOTES.md b/UPGRADE_NOTES.md new file mode 100644 index 0000000..cdd430a --- /dev/null +++ b/UPGRADE_NOTES.md @@ -0,0 +1,87 @@ +# Gunicorn Upgrade Fix - Issue #79 + +This document explains the fix for the failing Dependabot PR #65 that attempted to upgrade gunicorn. + +## Problem + +Dependabot attempted to upgrade gunicorn from version 22.0.0 to a newer version (likely 23.0.0), but the CI tests failed due to a breaking change in the gunicorn API. + +## Root Cause + +The test file `src/gunicorn_test.py` was using a deprecated import pattern: +```python +from gunicorn.app.wsgiapp import run +``` + +In gunicorn 23.x, this direct function import was deprecated in favor of using the proper application class. + +## Solution + +### Changes Made + +1. **Updated gunicorn version** in `src/requirements.txt`: + ```diff + - gunicorn==22.0.0 + + gunicorn==23.0.0 + ``` + +2. **Fixed import compatibility** in `src/gunicorn_test.py`: + ```diff + - from gunicorn.app.wsgiapp import run + + from gunicorn.app.wsgiapp import WSGIApplication + + def test_config_imports(): + argv = ["gunicorn", "--check-config", "api.main:app"] + + with mock.patch.object(sys, "argv", argv): + with pytest.raises(SystemExit) as excinfo: + - run() + + app = WSGIApplication() + + app.run() + + assert excinfo.value.args[0] == 0 + ``` + +### Why This Fix Works + +- The new pattern uses the proper gunicorn application class `WSGIApplication()` +- This class reads configuration from `sys.argv` (which we mock in the test) +- The `app.run()` method performs the same validation as the old `run()` function +- The test still validates that gunicorn can successfully parse the configuration + +## Verification + +To verify this fix works: + +1. Create a virtual environment: + ```bash + python3 -m venv .venv + source .venv/bin/activate + ``` + +2. Install dependencies: + ```bash + pip install -r requirements-dev.txt + ``` + +3. Run tests: + ```bash + python -m pytest + ``` + +4. Test gunicorn configuration: + ```bash + cd src + gunicorn --check-config api.main:app + ``` + +## Compatibility + +This fix maintains backward compatibility while supporting the newer gunicorn 23.x API. The configuration file `src/gunicorn.conf.py` requires no changes as all the settings used are stable across versions. + +## Alternative Installation Command + +If you encounter any issues, you can also install using the verification script: +```bash +python3 verify_installation.py +``` \ No newline at end of file