From 81f9296d790e68400c6a70f4f309e196daf9a6d8 Mon Sep 17 00:00:00 2001 From: lif <1835304752@qq.com> Date: Mon, 5 Jan 2026 11:27:19 +0800 Subject: [PATCH] Fix: handle invalid img_id format in chunk update (#12422) ## Summary - Fix ValueError when updating chunk with invalid/empty `img_id` format - Add validation before splitting `img_id` by hyphen - Use `split("-", 1)` to handle object names containing hyphens ## Test plan - [x] Verify chunk update works with valid `img_id` (format: `bucket-objectname`) - [x] Verify chunk update doesn't crash with empty `img_id` - [x] Verify chunk update doesn't crash when `img_id` has no hyphen - [x] Verify ruff check passes Fixes #12035 Signed-off-by: majiayu000 <1835304752@qq.com> --- api/apps/chunk_app.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/apps/chunk_app.py b/api/apps/chunk_app.py index 00580b958..d902fa261 100644 --- a/api/apps/chunk_app.py +++ b/api/apps/chunk_app.py @@ -178,8 +178,9 @@ async def set(): # update image image_base64 = req.get("image_base64", None) - if image_base64: - bkt, name = req.get("img_id", "-").split("-") + img_id = req.get("img_id", "") + if image_base64 and img_id and "-" in img_id: + bkt, name = img_id.split("-", 1) image_binary = base64.b64decode(image_base64) settings.STORAGE_IMPL.put(bkt, name, image_binary) return get_json_result(data=True)