Camera API silently starts with no cameras when credentials.json is unreadable

Open
#489 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, python
Domain
backend, devops

Research direction

Start with pyro_camera_api/core/config.py, where the issue shows credentials.json loading errors are swallowed, and inspect the compose configuration and README “Data directory” section. Check how the API handles unreadable credentials and how the engine writes data/heartbeat; decide whether errors should be logged or startup should fail, and clarify the required directory ownership. Done when the failure is visible and the deployment guidance covers the reported permissions.

Written by the indexing model from the issue text.

Description

What happens

pyro_camera_api/core/config.py swallows any error while loading credentials.json:

if CREDENTIALS_PATH.exists():
    try:
        with Path(CREDENTIALS_PATH).open("r", encoding="utf8") as f:
            RAW_CONFIG = json.load(f)
    except Exception:
        RAW_CONFIG = {}

With the compose hardening (cap_drop: [ALL], so no CAP_DAC_OVERRIDE for root), a credentials.json that is not owned by root (for example chmod 600 by the deploy user) cannot be read. The camera API then starts healthy with an empty registry: /cameras/cameras_list is empty, every /cameras/latest_image returns 404, and nothing in the logs says why.

In the same setup the engine crashes at start with PermissionError: [Errno 13] Permission denied: 'data/heartbeat' (the data directory is not writable by root without CAP_DAC_OVERRIDE).

Steps to reproduce

  1. chown -R 1000:1000 data && chmod 600 data/credentials.json
  2. docker compose up -d
  3. curl localhost:8081/cameras/cameras_list → {"camera_ids": []}, no error logged.

Suggestions

  • Log the exception (or fail fast) instead of silently using {}.
  • Document in the README "Data directory" section that ./data must be owned by root (or by the container user) because of cap_drop: ALL.
Dominant language
Python
Stars
21
Forks
10
Avg merge
4d 4h
Merged PRs (30d)
13

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pyronear/pyro-engine

All issues in pyronear/pyro-engine

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.