Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/api/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _normalize_postgres_url(url: str) -> str:

def get_engine_url() -> str:
"""Resolve the database URL from env or settings with sane defaults."""
settings = Settings()
settings = get_settings()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

🧩 Analysis chain

Verify that caching is actually implemented in get_settings().

The change correctly uses the factory function, but the provided code snippet from backend/api/config.py shows get_settings() simply returning Settings() without visible caching mechanism. Please verify that get_settings() actually implements caching (e.g., via @lru_cache() decorator) to achieve the stated goal of "reusing the shared cached settings instance."

Additionally, note that get_settings() appears in both backend/api/config.py and backend/api/security.py. Consider consolidating these implementations to avoid duplication and potential inconsistencies.

Run the following script to verify the caching implementation:


🏁 Script executed:

#!/bin/bash
# Description: Check if get_settings() uses caching decorator and identify duplicate implementations

# Check for caching decorators on get_settings() in config.py
echo "=== Checking config.py for caching implementation ==="
rg -A 5 -B 3 'def get_settings' backend/api/config.py

# Check for caching decorators on get_settings() in security.py
echo "=== Checking security.py for caching implementation ==="
rg -A 5 -B 3 'def get_settings' backend/api/security.py

# Search for lru_cache imports in both files
echo "=== Checking for lru_cache imports ==="
rg 'from functools import.*lru_cache' backend/api/config.py backend/api/security.py

Length of output: 576


Consolidate duplicate get_settings() implementations
config.py’s get_settings() is correctly cached via @lru_cache(). Please remove or unify the duplicate, uncached get_settings() in backend/api/security.py to avoid inconsistencies.

🤖 Prompt for AI Agents
In backend/api/db.py around line 32, you call get_settings() directly but there
is a duplicate, uncached get_settings() implementation in
backend/api/security.py; remove the duplicate implementation in security.py and
instead import the cached get_settings from the central config module (where
@lru_cache() is applied), update any imports/usages in both
backend/api/security.py and backend/api/db.py to use that single cached
function, and run tests/linters to ensure no unresolved imports remain.

url = os.getenv("DATABASE_URL", settings.database_url)
if url.startswith("sqlite"):
return url
Expand Down
Loading