From e7ecbf7d7bbbe26675ef83a645e36b1b01620d56 Mon Sep 17 00:00:00 2001 From: Marcin Zieba Date: Tue, 26 May 2026 19:48:55 +0200 Subject: [PATCH] fix: warn-and-skip on duplicate repo keys instead of crashing The upstream DTL repo legitimately contains files with the same model name but different part numbers (e.g. HPE 38L7559.yaml and 834167-001.yaml both have model 'HPE Drive LTO-7 Ultrium 7-SCSI'). Previously the loaders raised ValueError which crashed export-diff. Change all three loaders (_load_repo_device_types, _load_repo_module_types, _load_repo_rack_types) to log a verbose warning and keep the first-seen entry, matching the import path's behaviour when encountering same-name records. --- core/export.py | 18 ++++++++++++++---- uv.lock | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/core/export.py b/core/export.py index 064aae557..7e252d37f 100644 --- a/core/export.py +++ b/core/export.py @@ -513,7 +513,11 @@ def _load_repo_device_types(self) -> dict: if isinstance(data, dict) and "slug" in data: key = (mfr_slug, data["slug"]) if key in result: - raise ValueError(f"Duplicate repo device-type key {key!r}: {seen_files[key]} and {yaml_file}") + self.handle.verbose_log( + f"[yellow]Duplicate repo device-type key {key!r}: " + f"{seen_files[key]} and {yaml_file} — keeping first[/yellow]" + ) + continue result[key] = data seen_files[key] = yaml_file return result @@ -535,9 +539,11 @@ def _load_repo_module_types(self) -> dict: if mfr_slug: key = (mfr_slug, data["model"]) if key in result: - raise ValueError( - f"Duplicate repo module-type key {key!r}: {seen_files[key]} and {yaml_file}" + self.handle.verbose_log( + f"[yellow]Duplicate repo module-type key {key!r}: " + f"{seen_files[key]} and {yaml_file} — keeping first[/yellow]" ) + continue result[key] = data seen_files[key] = yaml_file return result @@ -559,7 +565,11 @@ def _load_repo_rack_types(self) -> dict: if mfr_slug: key = (mfr_slug, data["model"]) if key in result: - raise ValueError(f"Duplicate repo rack-type key {key!r}: {seen_files[key]} and {yaml_file}") + self.handle.verbose_log( + f"[yellow]Duplicate repo rack-type key {key!r}: " + f"{seen_files[key]} and {yaml_file} — keeping first[/yellow]" + ) + continue result[key] = data seen_files[key] = yaml_file return result diff --git a/uv.lock b/uv.lock index 23c2e8463..4576eb170 100644 --- a/uv.lock +++ b/uv.lock @@ -193,7 +193,7 @@ wheels = [ [[package]] name = "device-type-library-import" -version = "1.5.0" +version = "1.6.0" source = { virtual = "." } dependencies = [ { name = "gitpython" },