fix: Improve version retrieval logic with fallback mechanism and enhanced error handling

This commit is contained in:
Primakov Alexandr Alexandrovich 2025-10-13 18:07:19 +03:00
parent 1d953f554b
commit 9dadc490e2

View File

@ -134,15 +134,25 @@ async def health_check():
async def get_version(): async def get_version():
"""Get backend version""" """Get backend version"""
try: try:
# Try multiple possible locations
version_file = Path(__file__).parent.parent / "VERSION" version_file = Path(__file__).parent.parent / "VERSION"
if version_file.exists(): if version_file.exists():
version = version_file.read_text().strip() 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: except Exception as e:
print(f"Error reading version: {e}") print(f"Error reading version: {e}")
return {"version": "unknown"} import traceback
traceback.print_exc()
return {"version": "0.1.0"}
@app.websocket("/ws/reviews") @app.websocket("/ws/reviews")