Open source video conferencing app powered by LiveKit. Built with Django and React.
π(backend) read the Sentry release from pyproject.toml
briquetb159b2069594
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c48c4d5f..7179e310 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -25,6 +25,7 @@ and this project adheres to### Fixed+- π(backend) report the app release to Sentry instead of "NA"- π(backend) acknowledge unknown LiveKit webhook events instead of 422- ποΈ(backend) enforce display name setting on rename API- ποΈ(backend) reject inactive users in resource server backenddiff --git a/src/backend/core/tests/test_settings_release.py b/src/backend/core/tests/test_settings_release.pynew file mode 100644index 00000000..ad485344--- /dev/null+++ b/src/backend/core/tests/test_settings_release.py@@ -0,0 +1,47 @@+"""Unit tests for the get_release settings helper."""++import re++import pytest++from meet.settings import get_release++[email protected](name="base_dir")+def fixture_empty_base_dir(tmp_path, monkeypatch):+ """Point get_release at an empty directory."""+ monkeypatch.setattr("meet.settings.BASE_DIR", str(tmp_path))+ return tmp_path+++def test_get_release_reads_project_pyproject():+ """Should return the semantic version of the backend's pyproject.toml."""+ assert re.fullmatch(r"\d+\.\d+\.\d+", get_release())+++def test_get_release_reads_pyproject_version(base_dir):+ """Should return the version declared in the [project] table."""+ (base_dir / "pyproject.toml").write_text(+ '[project]\nname = "meet"\nversion = "1.2.3"\n', encoding="utf-8"+ )+ assert get_release() == "1.2.3"++[email protected]("base_dir")+def test_get_release_missing_pyproject():+ """Should fall back to "NA" without a pyproject.toml."""+ assert get_release() == "NA"+++ "content",+ [+ '[project]\nname = "meet"\n', # no version+ "[tool.uv]\npackage = true\n", # no [project] table+ "[project\nversion = ", # malformed TOML+ ],+)+def test_get_release_unreadable_version(base_dir, content):+ """Should fall back to "NA" without a readable version in pyproject.toml."""+ (base_dir / "pyproject.toml").write_text(content, encoding="utf-8")+ assert get_release() == "NA"diff --git a/src/backend/meet/settings.py b/src/backend/meet/settings.pyindex 35137d7c..2f434173 100755--- a/src/backend/meet/settings.py+++ b/src/backend/meet/settings.py@@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/# pylint: disable=too-many-lines-import json+import tomllibimport warningsfrom os import pathfrom socket import gethostbyname, gethostname@@ -37,19 +37,11 @@ GB = 1024 * MBdef get_release():"""Get the current release of the application-- By release, we mean the release from the version.json file Γ la Mozilla [1]- (if any). If this file has not been found, it defaults to "NA".-- [1]- https://github.com/mozilla-services/Dockerflow/blob/master/docs/version_object.md"""- # Try to get the current release from the version.json file generated by the- # CI during the Docker image buildtry:- with open(path.join(BASE_DIR, "version.json"), encoding="utf8") as version:- return json.load(version)["version"]- except FileNotFoundError:+ with open(path.join(BASE_DIR, "pyproject.toml"), "rb") as pyproject:+ return tomllib.load(pyproject)["project"]["version"]+ except (FileNotFoundError, KeyError, tomllib.TOMLDecodeError):return "NA" # Default: not available