WIP: UI编辑器自动分图层切图标 #304
@@ -264,11 +264,7 @@ pub async fn create_vector_engine_raw_image_edit(
|
||||
});
|
||||
}
|
||||
};
|
||||
let b64_images = payload
|
||||
.data
|
||||
.into_iter()
|
||||
.map(|entry| entry.b64_json)
|
||||
.collect::<Vec<_>>();
|
||||
let b64_images = collect_b64_images(payload.data);
|
||||
if b64_images.is_empty() {
|
||||
let message = format!("{failure_context}:上游未返回 b64_json 图片");
|
||||
let audit = build_failure_audit(
|
||||
@@ -299,6 +295,13 @@ pub async fn create_vector_engine_raw_image_edit(
|
||||
})
|
||||
}
|
||||
|
||||
fn collect_b64_images(data: Vec<RawImageEditResponseEntry>) -> Vec<String> {
|
||||
data.into_iter()
|
||||
.map(|entry| entry.b64_json)
|
||||
.filter(|value| !value.is_empty())
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn invalid_request(context: &str, message: String) -> PlatformImageError {
|
||||
PlatformImageError::InvalidRequest {
|
||||
provider: VECTOR_ENGINE_PROVIDER,
|
||||
@@ -415,6 +418,16 @@ mod tests {
|
||||
assert!(serde_json::from_str::<RawImageEditResponsePayload>(r#"{"data":[{}]}"#).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn raw_success_response_discards_empty_b64_json_entries() {
|
||||
let payload: RawImageEditResponsePayload = serde_json::from_str(
|
||||
r#"{"data":[{"b64_json":""},{"b64_json":"valid"}]}"#,
|
||||
)
|
||||
.expect("response envelope");
|
||||
|
||||
assert_eq!(collect_b64_images(payload.data), vec!["valid"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn raw_image_edit_dimensions_enforce_strict_contract() {
|
||||
assert!(validate_raw_image_edit_dimensions(1024, 640).is_ok());
|
||||
|
||||
Reference in New Issue
Block a user