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

オープン
#489 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
66/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
docker, python
領域
backend, devops

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
Python
スター
21
フォーク
10
平均マージ
4日 4時間
マージ済み PR(30日)
13

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pyronear/pyro-engine のほかの issue

pyronear/pyro-engine の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。