From 9dadc490e27b9347714e95d6d68e382490b277e1 Mon Sep 17 00:00:00 2001 From: Primakov Alexandr Alexandrovich Date: Mon, 13 Oct 2025 18:07:19 +0300 Subject: [PATCH] fix: Improve version retrieval logic with fallback mechanism and enhanced error handling --- backend/app/main.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/app/main.py b/backend/app/main.py index 87b1b2e..50aed0f 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -134,15 +134,25 @@ async def health_check(): async def get_version(): """Get backend version""" try: + # Try multiple possible locations version_file = Path(__file__).parent.parent / "VERSION" + if version_file.exists(): version = version_file.read_text().strip() - else: - version = "unknown" - return {"version": version} + return {"version": version} + + # Fallback: try root directory + root_version = Path(__file__).parent.parent.parent / "VERSION" + if root_version.exists(): + version = root_version.read_text().strip() + return {"version": version} + + return {"version": "0.1.0"} except Exception as e: print(f"Error reading version: {e}") - return {"version": "unknown"} + import traceback + traceback.print_exc() + return {"version": "0.1.0"} @app.websocket("/ws/reviews")