From 3f9b280708e4b2dcb69f7cba7f3fdce2af4a5952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sat, 3 Oct 2026 17:39:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=90=8E=E5=8F=B0=E6=8E=A5=E5=8F=A3):=20?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E5=95=86=E5=93=81=E4=B8=9A=E5=8A=A1=E6=8B=92?= =?UTF-8?q?=E7=BB=9D=E6=8C=89=20400=20=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - is_runtime_profile_membership_domain_error 增加 "会员商品 product_id 无法解析: " 与 "充值商品类型无效:会员商品已迁移到会员档位目录" 前缀匹配,避免这两类可读业务拒绝落到 502。 - 新增 membership_business_rejections_map_to_bad_request 覆盖升级拒绝、商品 id 解析失败与旧会员商品类型三条路径。 --- .../crates/api-server/src/runtime_profile.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/server-rs/crates/api-server/src/runtime_profile.rs b/server-rs/crates/api-server/src/runtime_profile.rs index 3627ab371..287cae8a6 100644 --- a/server-rs/crates/api-server/src/runtime_profile.rs +++ b/server-rs/crates/api-server/src/runtime_profile.rs @@ -1511,6 +1511,8 @@ fn is_runtime_profile_domain_error(message: &str) -> bool { fn is_runtime_profile_membership_domain_error(message: &str) -> bool { message.starts_with("会员升级被拒绝: ") || message.starts_with("会员档位") + || message.starts_with("会员商品 product_id 无法解析: ") + || message.starts_with("充值商品类型无效:会员商品已迁移到会员档位目录") || matches!( message, "当前不是会员,请直接选择套餐购买" @@ -2610,6 +2612,24 @@ mod tests { ); } + #[test] + fn membership_business_rejections_map_to_bad_request() { + // 中文注释:会员商品迁档位目录后的业务拒绝必须按 400 返回;漏掉前缀匹配会落到 502, + // 让后台与下单端把可读的业务提示当成基础设施故障。目录缺行属于部署配置错误,保持 502。 + for message in [ + "会员升级被拒绝: cycle_kind_change_unsupported", + "会员商品 product_id 无法解析: membership-pro-yearly", + "充值商品类型无效:会员商品已迁移到会员档位目录", + ] { + let error = map_runtime_profile_client_error(SpacetimeClientError::Procedure( + message.to_string(), + )); + + assert_eq!(error.status_code(), StatusCode::BAD_REQUEST, "{message}"); + assert_eq!(error.message(), message); + } + } + #[test] fn admin_profile_code_time_parser_accepts_optional_rfc3339_values() { assert_eq!(