From faa68adaa143774a8757fda4fd0248cc3aef551e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 12:15:12 +0000 Subject: [PATCH] fix: address code review feedback (assertion, exc_info logging) Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- app/middleware/upload_rate_limit.py | 4 ++-- tests/test_upload_rate_limit.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/middleware/upload_rate_limit.py b/app/middleware/upload_rate_limit.py index 949d3801..16b7d907 100644 --- a/app/middleware/upload_rate_limit.py +++ b/app/middleware/upload_rate_limit.py @@ -70,7 +70,7 @@ def _get_redis() -> redis.Redis | None: _redis_client.ping() return _redis_client except Exception: # noqa: BLE001 - logger.debug("Redis unavailable for upload rate limiter – falling back to allow-all") + logger.debug("Redis unavailable for upload rate limiter – falling back to allow-all", exc_info=True) _redis_client = None return None @@ -87,7 +87,7 @@ def _get_queue_depth(r: redis.Redis) -> int: try: total += r.llen(queue_name) except Exception: # noqa: BLE001, S110 - logger.debug("Could not read queue length for '%s'", queue_name) + logger.debug("Could not read queue length for %r", queue_name, exc_info=True) return total diff --git a/tests/test_upload_rate_limit.py b/tests/test_upload_rate_limit.py index b5430f0f..4e23e6dc 100644 --- a/tests/test_upload_rate_limit.py +++ b/tests/test_upload_rate_limit.py @@ -82,9 +82,10 @@ class TestComputeEffectiveLimit: """A base limit of 0 (disabled) should clamp to at least 1.""" effective, _factor, _reason = compute_effective_limit(0, queue_depth=0, cpu_load_ratio=0.0) # max(1, int(0 * 1.0)) = max(1, 0) = 1 - # This is correct since a base_limit of 0 means "disabled" and is - # handled upstream (the dependency skips the check entirely). - assert effective >= 0 + # A base_limit of 0 means "disabled" and is handled upstream + # (the dependency skips the check entirely), but the pure function + # still clamps to 1 as a safety net. + assert effective == 1 # ---------------------------------------------------------------------------