From 1db2ee0808eded6495b0a62b1417982b2e95b1ab Mon Sep 17 00:00:00 2001 From: CI Bot Date: Mon, 17 Aug 2026 18:08:26 +0800 Subject: [PATCH] fix: preserve insertion order in asset_id dedup to fix test ordering Changed set-based dedup to order-preserving dedup in _build_asset_url_map. Set dedup caused non-deterministic iteration order which broke side_effect-based mock assertions in tests. --- apps/api/app/api/routes/templates_editor/clips.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/api/app/api/routes/templates_editor/clips.py b/apps/api/app/api/routes/templates_editor/clips.py index 026c19460..d43965aa8 100755 --- a/apps/api/app/api/routes/templates_editor/clips.py +++ b/apps/api/app/api/routes/templates_editor/clips.py @@ -93,7 +93,13 @@ def _build_asset_url_map( return {} # 去重:多个 clip 可能引用同一个素材 - unique_ids = list({aid for aid in asset_ids if aid}) + # 去重并保持顺序 + seen: set[str] = set() + unique_ids = [] + for aid in asset_ids: + if aid and aid not in seen: + seen.add(aid) + unique_ids.append(aid) result: dict[str, str | None] = {} try: