From f2c73308006176e3b0fdce778132a08b82eaa54a Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Tue, 19 May 2026 13:36:42 -0700 Subject: [PATCH] fix(assets): validate sibling dimensions before backfilling Per CodeRabbit review on #13991: the previous loop accepted any sibling with `kind == "image"` and copied whichever dimension keys happened to be present, then returned. A partial sibling (kind set but missing or invalid width/height) could persist incomplete metadata onto the new reference even when a later sibling had valid dimensions. Now we validate that the sibling has both width and height as positive integers before adopting its dimensions, and continue scanning to the next sibling otherwise. --- app/assets/services/ingest.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/assets/services/ingest.py b/app/assets/services/ingest.py index afc0f48f4..5716f3d5b 100644 --- a/app/assets/services/ingest.py +++ b/app/assets/services/ingest.py @@ -411,10 +411,19 @@ def _backfill_image_dimensions_from_siblings( meta = sibling.system_metadata or {} if meta.get("kind") != "image": continue + width = meta.get("width") + height = meta.get("height") + if ( + not isinstance(width, int) + or not isinstance(height, int) + or width <= 0 + or height <= 0 + ): + continue merged = dict(current) - for key in _IMAGE_DIMENSION_KEYS: - if key in meta: - merged[key] = meta[key] + merged["kind"] = "image" + merged["width"] = width + merged["height"] = height if merged != current: set_reference_system_metadata( session,