mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-02 03:29:03 +00:00
Check for empty payload (#2903)
This commit is contained in:
parent
1e556d2ac1
commit
1656ca460c
@ -83,6 +83,13 @@ class InvalidEntityException(Exception):
|
||||
"""
|
||||
|
||||
|
||||
class EmptyPayloadException(Exception):
|
||||
"""
|
||||
Raise when receiving no data, even if no exception
|
||||
during the API call is received
|
||||
"""
|
||||
|
||||
|
||||
class EntityList(Generic[T], BaseModel):
|
||||
"""
|
||||
Pydantic Entity list model
|
||||
@ -363,6 +370,10 @@ class OpenMetadata(
|
||||
)
|
||||
|
||||
resp = self.client.put(self.get_suffix(entity), data=data.json())
|
||||
if not resp:
|
||||
raise EmptyPayloadException(
|
||||
f"Got an empty response when trying to PUT to {self.get_suffix(entity)}, {data.json()}"
|
||||
)
|
||||
return entity_class(**resp)
|
||||
|
||||
def get_by_name(
|
||||
@ -398,6 +409,10 @@ class OpenMetadata(
|
||||
fields_str = "?fields=" + ",".join(fields) if fields else ""
|
||||
try:
|
||||
resp = self.client.get(f"{self.get_suffix(entity)}/{path}{fields_str}")
|
||||
if not resp:
|
||||
raise EmptyPayloadException(
|
||||
f"Got an empty response when trying to GET from {self.get_suffix(entity)}/{path}{fields_str}"
|
||||
)
|
||||
return entity(**resp)
|
||||
except APIError as err:
|
||||
logger.error(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user