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)