diff --git a/CHANGELOG.md b/CHANGELOG.md index fce3496..f084123 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### Bug fixes -- Validation error path field can be empty +- Validation error path field can be empty (#52) ## v0.10.5 (2024-03-07) diff --git a/cerbos/sdk/_async/_http.py b/cerbos/sdk/_async/_http.py index 3de54c7..09994f1 100644 --- a/cerbos/sdk/_async/_http.py +++ b/cerbos/sdk/_async/_http.py @@ -196,7 +196,12 @@ 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 + resp = await self._http.post( + "/api/check/resources", + json={k: v for k, v in req.to_dict().items() if v is not None}, + ) if resp.is_error: if self._raise_on_error: raise CerbosRequestException(APIError.from_dict(resp.json())) @@ -265,7 +270,10 @@ async def plan_resources( aux_data=aux_data, ) - resp = await self._http.post("/api/plan/resources", json=req.to_dict()) + resp = await self._http.post( + "/api/plan/resources", + json={k: v for k, v in req.to_dict().items() if v is not None}, + ) if resp.is_error: if self._raise_on_error: raise CerbosRequestException(APIError.from_dict(resp.json())) diff --git a/cerbos/sdk/_sync/_http.py b/cerbos/sdk/_sync/_http.py index 5b3948a..a297dc7 100644 --- a/cerbos/sdk/_sync/_http.py +++ b/cerbos/sdk/_sync/_http.py @@ -196,7 +196,12 @@ 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 + resp = self._http.post( + "/api/check/resources", + json={k: v for k, v in req.to_dict().items() if v is not None}, + ) if resp.is_error: if self._raise_on_error: raise CerbosRequestException(APIError.from_dict(resp.json())) @@ -265,7 +270,10 @@ def plan_resources( aux_data=aux_data, ) - resp = self._http.post("/api/plan/resources", json=req.to_dict()) + resp = self._http.post( + "/api/plan/resources", + json={k: v for k, v in req.to_dict().items() if v is not None}, + ) if resp.is_error: if self._raise_on_error: raise CerbosRequestException(APIError.from_dict(resp.json()))