From 685918f02d764bea56e2aafb432a5b6501354d5d Mon Sep 17 00:00:00 2001 From: Bob Haddleton Date: Wed, 18 Dec 2024 14:27:11 -0600 Subject: [PATCH] Bump protobuf and add defensive checks to get_* helpers Signed-off-by: Bob Haddleton --- crossplane/function/resource.py | 8 ++++---- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crossplane/function/resource.py b/crossplane/function/resource.py index 322a482..ac08c0e 100644 --- a/crossplane/function/resource.py +++ b/crossplane/function/resource.py @@ -110,10 +110,10 @@ def get_condition(resource: structpb.Struct, typ: str) -> Condition: """ unknown = Condition(typ=typ, status="Unknown") - if "status" not in resource: + if not resource or "status" not in resource: return unknown - if "conditions" not in resource["status"]: + if not resource["status"] or "conditions" not in resource["status"]: return unknown for c in resource["status"]["conditions"]: @@ -149,9 +149,9 @@ class Credentials: def get_credentials(req: structpb.Struct, name: str) -> Credentials: """Get the supplied credentials.""" empty = Credentials(type="data", data={}) - if "credentials" not in req: + if not req or "credentials" not in req: return empty - if name not in req["credentials"]: + if not req["credentials"] or name not in req["credentials"]: return empty return Credentials( type=req["credentials"][name]["type"], diff --git a/pyproject.toml b/pyproject.toml index 13b418d..1025850 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ classifiers = [ dependencies = [ "grpcio==1.*", "grpcio-reflection==1.*", - "protobuf==5.27.2", + "protobuf==5.28.1", "pydantic==2.*", "structlog==24.*", ]