mirror of
https://github.com/stack-auth/stack.git
synced 2026-07-20 21:29:36 +08:00
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:
parent
37118e0871
commit
cac86efd17
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user