From 7914bf1a756b5dd7ca9867e1a5571117a6875ac8 Mon Sep 17 00:00:00 2001 From: tiga <68499559+SheepSheepChen@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:25:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20update=5Fapp=5Fresource=20=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E6=B7=BB=E5=8A=A0=20metadata=20=E6=A0=A1=E9=AA=8C=20(?= =?UTF-8?q?#1544)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../paas_wl/bk_app/cnative/specs/models/app_resource.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apiserver/paasng/paas_wl/bk_app/cnative/specs/models/app_resource.py b/apiserver/paasng/paas_wl/bk_app/cnative/specs/models/app_resource.py index 36b5dd0ce2..79ec0d1ac1 100644 --- a/apiserver/paasng/paas_wl/bk_app/cnative/specs/models/app_resource.py +++ b/apiserver/paasng/paas_wl/bk_app/cnative/specs/models/app_resource.py @@ -242,8 +242,11 @@ def update_app_resource(app: Application, module: Module, payload: Dict): :raise: `ValidationError` when payload is invalid :raise: `ValueError` if model resource has not been initialized for given application """ - # force replace metadata.name with app_code to avoid user modify - payload["metadata"]["name"] = generate_bkapp_name(module) + try: + # force replace metadata.name with app_code to avoid user modify + payload["metadata"]["name"] = generate_bkapp_name(module) + except KeyError as e: + raise ValidationError(f"Missing field in manifest: {e}") try: obj = BkAppResource(**payload)