diff --git a/packages/http-client-python/generator/pygen/codegen/__init__.py b/packages/http-client-python/generator/pygen/codegen/__init__.py index 074b5854c8..ce8368d417 100644 --- a/packages/http-client-python/generator/pygen/codegen/__init__.py +++ b/packages/http-client-python/generator/pygen/codegen/__init__.py @@ -245,7 +245,7 @@ def _validate_code_model_options(self) -> None: @staticmethod def sort_exceptions(yaml_data: Dict[str, Any]) -> None: for client in yaml_data["clients"]: - for group in client["operationGroups"]: + for group in client.get("operationGroups", []): for operation in group["operations"]: if not operation.get("exceptions"): continue @@ -262,7 +262,7 @@ def sort_exceptions(yaml_data: Dict[str, Any]) -> None: @staticmethod def remove_cloud_errors(yaml_data: Dict[str, Any]) -> None: for client in yaml_data["clients"]: - for group in client["operationGroups"]: + for group in client.get("operationGroups", []): for operation in group["operations"]: if not operation.get("exceptions"): continue