Skip to content

Agent crashes on startup with FileNotFoundError when git is not installed #8

Description

@t0kubetsu

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

  1. Install the agent on a system without git (or run it in a container where git is absent).
  2. 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):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions