Skip to content

Commit

Permalink
omit check_request params with None values
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Lock <[email protected]>
  • Loading branch information
Sambigeara committed Dec 19, 2024
1 parent da53079 commit 0b3b2a1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion cerbos/sdk/_async/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ async def check_resources(
resources=resources.resources,
aux_data=aux_data,
)
resp = await self._http.post("/api/check/resources", json=req.to_dict())

# omit keys with `None` values
req_params = {k: v for k, v in req.to_dict().items() if v is not None}

resp = await self._http.post("/api/check/resources", json=req_params)
if resp.is_error:
if self._raise_on_error:
raise CerbosRequestException(APIError.from_dict(resp.json()))
Expand Down
6 changes: 5 additions & 1 deletion cerbos/sdk/_sync/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ def check_resources(
resources=resources.resources,
aux_data=aux_data,
)
resp = self._http.post("/api/check/resources", json=req.to_dict())

# omit keys with `None` values
req_params = {k: v for k, v in req.to_dict().items() if v is not None}

resp = self._http.post("/api/check/resources", json=req_params)
if resp.is_error:
if self._raise_on_error:
raise CerbosRequestException(APIError.from_dict(resp.json()))
Expand Down
6 changes: 4 additions & 2 deletions cerbos/sdk/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ def __init__(self, error: Optional[APIError]):
self.error = error


class CerbosTLSError(Exception): ...
class CerbosTLSError(Exception):
...


class CerbosTypeError(Exception): ...
class CerbosTypeError(Exception):
...

0 comments on commit 0b3b2a1

Please sign in to comment.