From 93f416b9226c913cea1ad05a5a7ebdba75b773a9 Mon Sep 17 00:00:00 2001 From: maziggy Date: Fri, 6 Feb 2026 12:32:29 +0100 Subject: [PATCH] Fix trivial conditionals, commented-out code, and dead variables (CodeQL) Simplify always-true authEnabled ternary and localSettings truthiness checks in SettingsPage.tsx. Remove commented-out auth re-setup guard and its dead _existing_setting/_user_count queries from auth.py. Add clarifying comments to firmware_check.py api_key logs (model identifier, not a secret). --- backend/app/api/routes/auth.py | 15 --------------- backend/app/services/firmware_check.py | 2 ++ frontend/src/pages/SettingsPage.tsx | 14 +++++++------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/backend/app/api/routes/auth.py b/backend/app/api/routes/auth.py index a1f3a15ac..7036a3d20 100644 --- a/backend/app/api/routes/auth.py +++ b/backend/app/api/routes/auth.py @@ -87,21 +87,6 @@ async def setup_auth(request: SetupRequest, db: AsyncSession = Depends(get_db)): logger = logging.getLogger(__name__) try: - # Check if auth is already configured (prevent re-setup) - result = await db.execute(select(Settings).where(Settings.key == "auth_enabled")) - _existing_setting = result.scalar_one_or_none() - - # Check if users exist - user_count_result = await db.execute(select(User)) - _user_count = len(user_count_result.scalars().all()) - - # if _existing_setting and _user_count > 0: - # # Auth already configured and users exist - prevent re-setup - # raise HTTPException( - # status_code=status.HTTP_400_BAD_REQUEST, - # detail="Authentication is already configured. Use user management to modify users.", - # ) - # If auth_enabled is true but no users exist, allow re-setup (recovery scenario) admin_created = False diff --git a/backend/app/services/firmware_check.py b/backend/app/services/firmware_check.py index c1b3ed73f..c2bcb00e0 100644 --- a/backend/app/services/firmware_check.py +++ b/backend/app/services/firmware_check.py @@ -135,9 +135,11 @@ class FirmwareCheckService: release_time=latest.get("release_time"), ) else: + # api_key is a printer model identifier (e.g. "x1", "p1"), not a secret logger.warning("Failed to fetch firmware for %s: %s", api_key, response.status_code) except (httpx.HTTPError, OSError, KeyError, ValueError) as e: + # api_key is a printer model identifier (e.g. "x1", "p1"), not a secret logger.error("Error fetching firmware for %s: %s", api_key, e) return None diff --git a/frontend/src/pages/SettingsPage.tsx b/frontend/src/pages/SettingsPage.tsx index bae3e1f26..6d7f7468b 100644 --- a/frontend/src/pages/SettingsPage.tsx +++ b/frontend/src/pages/SettingsPage.tsx @@ -1022,7 +1022,7 @@ export function SettingsPage() { {t('settings.tabs.users')} {authEnabled && ( - + )}