fix: add None guard before model_validate in get_item methods

Both sync and async get_item() were missing the None check that other
getters (get_user, get_team) already have. An empty response body would
surface as a pydantic ValidationError instead of a meaningful NotFoundError.
This commit is contained in:
Ejiro Asiuwhu 2026-03-26 09:44:19 +01:00
parent 37118e0871
commit cac86efd17

View File

@ -1248,6 +1248,8 @@ class StackServerApp:
data = self._client.request(
"GET", f"/customers/{ctype}/{cid}/items/{item_id}"
)
if data is None:
raise NotFoundError(code="ITEM_NOT_FOUND", message=f"Item '{item_id}' not found")
item = Item.model_validate(data)
return ServerItem(
item,
@ -2584,6 +2586,8 @@ class AsyncStackServerApp:
data = await self._client.request(
"GET", f"/customers/{ctype}/{cid}/items/{item_id}"
)
if data is None:
raise NotFoundError(code="ITEM_NOT_FOUND", message=f"Item '{item_id}' not found")
item = Item.model_validate(data)
return AsyncServerItem(
item,