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 <noreply@anthropic.com>
This commit is contained in:
dom
2026-10-05 15:55:37 +02:00
co-authored by Claude Opus 5.5
parent 0f574cccde
commit cb2566a537
2 changed files with 6 additions and 5 deletions
+5 -4
View File
@@ -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"