From e359158ecf939176d40fa4cf5c9dcf1ded41bfab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Tue, 22 Sep 2026 16:19:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E6=96=87=E6=A1=88=E7=9A=84?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=A0=87=E7=AD=BE=E6=94=B9=E4=B8=BA=E4=BB=8E?= =?UTF-8?q?=E5=A5=91=E7=BA=A6=E6=9E=9A=E4=B8=BE=E6=8E=A8=E5=AF=BC=20-=20va?= =?UTF-8?q?lidate=5Fgeneration=5Foptions=20=E7=9A=84=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=96=87=E6=A1=88=E6=94=B9=E7=94=A8=20wire=5Fstr=5Flossy=20?= =?UTF-8?q?=E5=8F=96=20serde=20=E7=BA=BF=E4=B8=8A=E5=80=BC=20-=20v3.x=20?= =?UTF-8?q?=E5=AE=B6=E6=97=8F=E7=9A=84=E6=A8=A1=E5=9E=8B=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E6=94=B6=E6=95=9B=E5=88=B0=20v3=5Fmodel=5Flabels=20=E5=8A=A9?= =?UTF-8?q?=E6=89=8B=20-=20=E5=A5=91=E7=BA=A6=E6=94=B9=E5=90=8D=E5=90=8E?= =?UTF-8?q?=E8=AF=8A=E6=96=AD=E6=96=87=E6=A1=88=E9=9A=8F=E4=B9=8B=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=EF=BC=8C=E4=B8=8D=E5=86=8D=E6=89=8B=E5=86=99=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E7=9A=84=E7=89=88=E6=9C=AC=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform-tripo/src/common/validation.rs | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/server-rs/crates/platform-tripo/src/common/validation.rs b/server-rs/crates/platform-tripo/src/common/validation.rs index 6cb502b0c..b91972bc8 100644 --- a/server-rs/crates/platform-tripo/src/common/validation.rs +++ b/server-rs/crates/platform-tripo/src/common/validation.rs @@ -5,6 +5,7 @@ use shared_contracts::model3d::common::{ use shared_contracts::model3d::image_to_model::Model3dImageToModelParams; use shared_contracts::model3d::multiview_to_model::Model3dMultiviewToModelRequest; use shared_contracts::model3d::text_to_model::Model3dTextToModelParams; +use shared_contracts::model3d::wire_str_lossy; use super::{TripoError, TripoField, TripoTaskHandle, TripoValidationReason}; @@ -65,6 +66,18 @@ tripo_generation_options_from! { compress, } +/// v3.x 家族的模型标签,供「只支持 v3.x」类错误文案复用。 +/// +/// 标签取自契约枚举的 serde 取值([`wire_str_lossy`]),契约改名后文案跟着变, +/// 这里不再手写第二份版本字符串。 +fn v3_model_labels() -> String { + format!( + "{} and {}", + wire_str_lossy(&Model3dModelVersion::H31), + wire_str_lossy(&Model3dModelVersion::H30) + ) +} + pub(crate) fn validate_generation_options( options: &TripoGenerationOptions, ) -> Result<(), TripoError> { @@ -74,7 +87,10 @@ pub(crate) fn validate_generation_options( return Err(invalid( Some(TripoField::TextureQuality), TripoValidationReason::InvalidCombination, - "texture_quality is not supported by v2.5-20250123", + &format!( + "texture_quality is not supported by {}", + wire_str_lossy(&Model3dModelVersion::H25) + ), )); } @@ -85,7 +101,10 @@ pub(crate) fn validate_generation_options( return Err(invalid( Some(TripoField::TextureQuality), TripoValidationReason::InvalidCombination, - "texture_quality=fast requires texture_version=v3.5-20260815", + &format!( + "texture_quality=fast requires texture_version={}", + wire_str_lossy(&Model3dTextureVersion::V35) + ), )); } @@ -94,7 +113,10 @@ pub(crate) fn validate_generation_options( return Err(invalid( Some(TripoField::GeometryQuality), TripoValidationReason::InvalidCombination, - "geometry_quality is only supported by v3.1-20260211 and v3.0-20250812", + &format!( + "geometry_quality is only supported by {}", + v3_model_labels() + ), )); } @@ -102,7 +124,7 @@ pub(crate) fn validate_generation_options( return Err(invalid( Some(TripoField::Compress), TripoValidationReason::InvalidCombination, - "compress is only supported by v3.1-20260211 and v3.0-20250812", + &format!("compress is only supported by {}", v3_model_labels()), )); } @@ -110,7 +132,10 @@ pub(crate) fn validate_generation_options( return Err(invalid( Some(TripoField::AutoSize), TripoValidationReason::InvalidCombination, - "auto_size is not supported by v2.5-20250123", + &format!( + "auto_size is not supported by {}", + wire_str_lossy(&Model3dModelVersion::H25) + ), )); } @@ -121,7 +146,7 @@ pub(crate) fn validate_generation_options( return Err(invalid( Some(TripoField::SmartLowPoly), TripoValidationReason::InvalidCombination, - "smart_low_poly is only supported by v3.1-20260211 and v3.0-20250812", + &format!("smart_low_poly is only supported by {}", v3_model_labels()), )); } @@ -132,7 +157,7 @@ pub(crate) fn validate_generation_options( return Err(invalid( Some(TripoField::GenerateParts), TripoValidationReason::InvalidCombination, - "generate_parts is only supported by v3.1-20260211 and v3.0-20250812", + &format!("generate_parts is only supported by {}", v3_model_labels()), )); } @@ -145,7 +170,10 @@ pub(crate) fn validate_generation_options( return Err(invalid( Some(TripoField::Quad), TripoValidationReason::InvalidCombination, - "quad=true is only supported by v3.x models and P2-20260801", + &format!( + "quad=true is only supported by v3.x models and {}", + wire_str_lossy(&Model3dModelVersion::P2) + ), )); }