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

Đang mở
#489 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
66/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker, python
Lĩnh vực
backend, devops

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Python
Star
21
Fork
10
Merge trung bình
4 ngày 4 giờ
Pull request đã merge (30 ngày)
13

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pyronear/pyro-engine

Tất cả issue của pyronear/pyro-engine

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.