Skip to content

Commit 685918f

Browse files
committed
Bump protobuf and add defensive checks to get_* helpers
Signed-off-by: Bob Haddleton <[email protected]>
1 parent 9c44291 commit 685918f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

crossplane/function/resource.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ def get_condition(resource: structpb.Struct, typ: str) -> Condition:
110110
"""
111111
unknown = Condition(typ=typ, status="Unknown")
112112

113-
if "status" not in resource:
113+
if not resource or "status" not in resource:
114114
return unknown
115115

116-
if "conditions" not in resource["status"]:
116+
if not resource["status"] or "conditions" not in resource["status"]:
117117
return unknown
118118

119119
for c in resource["status"]["conditions"]:
@@ -149,9 +149,9 @@ class Credentials:
149149
def get_credentials(req: structpb.Struct, name: str) -> Credentials:
150150
"""Get the supplied credentials."""
151151
empty = Credentials(type="data", data={})
152-
if "credentials" not in req:
152+
if not req or "credentials" not in req:
153153
return empty
154-
if name not in req["credentials"]:
154+
if not req["credentials"] or name not in req["credentials"]:
155155
return empty
156156
return Credentials(
157157
type=req["credentials"][name]["type"],

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ classifiers = [
1919
dependencies = [
2020
"grpcio==1.*",
2121
"grpcio-reflection==1.*",
22-
"protobuf==5.27.2",
22+
"protobuf==5.28.1",
2323
"pydantic==2.*",
2424
"structlog==24.*",
2525
]

0 commit comments

Comments
 (0)