From cb2566a537714ec010b8cc8e5191ff32955bff85 Mon Sep 17 00:00:00 2001 From: Dominik Dachs Date: Mon, 5 Oct 2026 15:55:06 +0200 Subject: [PATCH] Accept icu_cameratrap_rep as camera trap image event type ICU sends "icu_cameratrap_rep" instead of the documented Gundi/EarthRanger type "cameratrap_rep". Events of the unknown type were stored as IGNORED, so the following attachment upload got 404 and no image was ingested. Treat both names as image events. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- gundi_pipeline.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0b8357a..f4e9220 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ ICU pusht Events ueber eine Gundi-v2-kompatible API. Der Service `gundi-receiver | Route | Zweck | |-------|-------| -| `POST /v2/events/` | `camera_status_report` oder `cameratrap_rep` (JSON, Objekt oder Liste) | +| `POST /v2/events/` | `camera_status_report` oder `cameratrap_rep` / `icu_cameratrap_rep` (JSON, Objekt oder Liste) | | `POST /v2/events//attachments/` | JPEG zum `cameratrap_rep` (multipart/form-data) | | `GET /healthz` | Healthcheck | diff --git a/gundi_pipeline.py b/gundi_pipeline.py index cc2b295..458b7b3 100644 --- a/gundi_pipeline.py +++ b/gundi_pipeline.py @@ -30,7 +30,8 @@ SCHEMA_FILE = Path(__file__).resolve().parent / "schema" / "001_domain_model.sql SCHEMA_LOCK_KEY = 7_311_000_001 UUID_STRICT_RE = re.compile(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$") -EVENT_CAMERATRAP = "cameratrap_rep" +# ICU sendet "icu_cameratrap_rep" (Gundi/EarthRanger-Standard waere "cameratrap_rep"); beide gelten als Bild-Event. +EVENT_CAMERATRAP_TYPES = ("cameratrap_rep", "icu_cameratrap_rep") EVENT_STATUS = "camera_status_report" MIN_API_KEY_LEN = 24 @@ -184,7 +185,7 @@ def validate_event(ev) -> dict: details = {} if not isinstance(details, dict): raise EventError("event_details muss ein Objekt sein") - if event_type == EVENT_CAMERATRAP: + if event_type in EVENT_CAMERATRAP_TYPES: dets = details.get("detections", []) if not isinstance(dets, list) or not all(isinstance(d, dict) for d in dets): raise EventError("event_details.detections muss eine Liste von Objekten sein") @@ -300,7 +301,7 @@ def store_events(dsn: str, items: list[tuple[dict, dict]]) -> list[dict]: object_id = str(uuidlib.uuid4()) if env["event_type"] == EVENT_STATUS: state = "INGESTED" - elif env["event_type"] == EVENT_CAMERATRAP: + elif env["event_type"] in EVENT_CAMERATRAP_TYPES: state = "AWAITING_ATTACHMENT" else: state = "IGNORED" @@ -335,7 +336,7 @@ def attach_image(dsn: str, s3: S3, gcfg: GundiConfig, object_id: str, jpg: bytes (object_id,), ) row = cur.fetchone() - if not row or row[0] != EVENT_CAMERATRAP: + if not row or row[0] not in EVENT_CAMERATRAP_TYPES: raise LookupError(object_id) if row[1] in ("RECEIVED", "INGESTED"): return "duplicate"