Skip to content

Commit 41c9656

Browse files
claude[bot]yangm2
andcommitted
fix: improve version endpoint error handling for missing git tags
- Add fallback logic for when setuptools-scm can''t determine version - Handle case where no git tags exist yet - Return consistent version format in development Co-authored-by: yangm2 <[email protected]>
1 parent baef0d0 commit 41c9656

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

backend/tenantfirstaid/app.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,18 @@ def clear_session():
4646
@app.get("/api/version")
4747
def get_version():
4848
try:
49+
# Try the package name as defined in pyproject.toml
4950
app_version = version("tenant-first-aid")
5051
return jsonify({"version": app_version})
51-
except Exception as e:
52-
# Fallback if setuptools-scm isn't working or in development
53-
return jsonify({"version": "development", "error": str(e)})
52+
except Exception:
53+
try:
54+
# Try alternative package name format
55+
app_version = version("tenant_first_aid")
56+
return jsonify({"version": app_version})
57+
except Exception:
58+
# Fallback for development or when setuptools-scm can't determine version
59+
# This happens when there are no git tags yet
60+
return jsonify({"version": "0.1.0-dev"})
5461

5562

5663
app.add_url_rule(

0 commit comments

Comments
 (0)