From 49965ddd7e2669111d5c4d2ebc2068a3899fd3f1 Mon Sep 17 00:00:00 2001 From: Linghong Date: Wed, 29 Jul 2026 11:27:11 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A7=92=E8=89=B2=E5=B0=BA?= =?UTF-8?q?=E5=AF=B8=E6=81=A2=E5=A4=8D=E9=99=8D=E7=BA=A7=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E5=B7=B2=E7=B4=AF=E7=A7=AF=E7=94=9F=E6=88=90=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit generate_editor_image_for_owner 的角色透明图尺寸恢复失败分支直接返回 warning: Some(...),没有合并 generation_warning,导致 style 为未知值时 契约承诺的 unsupported-image-style 告警在该降级路径上消失。 改为经 merge_editor_generation_warnings 合并,与该函数另外两个返回点一致。 新增结构断言固定"普通图片与图标生成的所有返回点都不得出现裸 warning: Some(", 并同步角色降级断言到合并后的形状。 Co-Authored-By: Claude Opus 5 --- .../crates/api-server/src/editor_project.rs | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/server-rs/crates/api-server/src/editor_project.rs b/server-rs/crates/api-server/src/editor_project.rs index 05a692290..9d6dd2861 100644 --- a/server-rs/crates/api-server/src/editor_project.rs +++ b/server-rs/crates/api-server/src/editor_project.rs @@ -2082,10 +2082,15 @@ pub(crate) async fn generate_editor_image_for_owner( resource: source_record.resource, asset: source_record.asset, project: completed_project, - warning: Some(editor_postprocess_fallback_warning_with_dimension( - "生成任务成功,后处理失败。", - dimension_warning.as_ref(), - )), + // 中文注释:原图安全降级同样要保留此前累积的告警(例如未知 style 的 + // unsupported-image-style),不能被后处理降级告警整条覆盖。 + warning: merge_editor_generation_warnings( + generation_warning, + Some(editor_postprocess_fallback_warning_with_dimension( + "生成任务成功,后处理失败。", + dimension_warning.as_ref(), + )), + ), }, )); } @@ -9285,6 +9290,26 @@ mod tests { ); } + #[test] + fn editor_image_generation_returns_never_drop_accumulated_warnings() { + let source = include_str!("editor_project.rs"); + // 中文注释:generation_warning 承载未知 style 的 unsupported-image-style 等 + // 累积告警,普通图片与角色生成的每一个返回点都必须经 merge 合并;任何 + // 直接的 `warning: Some(` 都会把此前累积的告警整条覆盖掉。 + for (start, end) in [ + ( + "pub(crate) async fn generate_editor_image_for_owner", + "fn editor_image_generation_billing_asset_kind", + ), + ( + "async fn generate_editor_icon_spritesheet_for_owner", + "fn slice_editor_icon_spritesheet_all", + ), + ] { + assert_function_not_contains(source, start, end, &["warning: Some("]); + } + } + #[test] fn pixel_art_degrade_paths_guard_postprocessed_delivery_dimensions() { let source = include_str!("editor_project.rs"); @@ -12229,7 +12254,11 @@ mod tests { "complete_editor_canvas_generation", "source_record.resource.as_ref()", "return Ok(json_success_body", - "warning: Some(editor_postprocess_fallback_warning", + // 中文注释:原图安全降级必须合并此前累积的告警,而不是整条覆盖, + // 同时仍要带上后处理降级告警本身。 + "warning: merge_editor_generation_warnings(", + "generation_warning", + "editor_postprocess_fallback_warning", ] { assert!( dimension_fallback_body.contains(snippet),