Description
get_version() in src/utils/mutils.py calls git describe --tags via subprocess.check_output. When git is not installed on the host (e.g. in a minimal Docker image or a stripped-down deployment), Python raises FileNotFoundError which is not caught by the current except CalledProcessError handler.
This causes the agent to crash at import time — before any configuration is loaded — because meta.py calls get_version() at module level.
Steps to reproduce
- Install the agent on a system without
git (or run it in a container where git is absent).
- Run
python agent.py -d ...
Error
Traceback (most recent call last):
File "/app/src/agent.py", line 20, in <module>
from utils.meta import print_meta
File "/app/src/utils/meta.py", line 12, in <module>
APP_VERSION = f"{get_version()}"
File "/app/src/utils/mutils.py", line 27, in get_version
subprocess.check_output(
FileNotFoundError: [Errno 2] No such file or directory: 'git'
Root cause
get_version() already handles the case where git is present but fails (CalledProcessError). It does not handle the case where the git binary cannot be found at all (FileNotFoundError, a subclass of OSError).
Fix
Widen both except clauses from CalledProcessError to (CalledProcessError, OSError) so a missing git binary falls through to "unknown" gracefully, matching the intent of the existing fallback chain.
# before
except CalledProcessError:
# after
except (CalledProcessError, OSError):
Description
get_version()insrc/utils/mutils.pycallsgit describe --tagsviasubprocess.check_output. Whengitis not installed on the host (e.g. in a minimal Docker image or a stripped-down deployment), Python raisesFileNotFoundErrorwhich is not caught by the currentexcept CalledProcessErrorhandler.This causes the agent to crash at import time — before any configuration is loaded — because
meta.pycallsget_version()at module level.Steps to reproduce
git(or run it in a container wheregitis absent).python agent.py -d ...Error
Root cause
get_version()already handles the case wheregitis present but fails (CalledProcessError). It does not handle the case where thegitbinary cannot be found at all (FileNotFoundError, a subclass ofOSError).Fix
Widen both
exceptclauses fromCalledProcessErrorto(CalledProcessError, OSError)so a missinggitbinary falls through to"unknown"gracefully, matching the intent of the existing fallback chain.