Skip to content

Commit

Permalink
Fix deploy bug in service registration; fix silent json status errors…
Browse files Browse the repository at this point in the history
… from lambda invoke
  • Loading branch information
emdoyle committed Aug 23, 2024
1 parent 34cd15f commit 9f85faa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/pare/cli/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def register_services(self) -> list[ServiceConfig]:
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
for name, obj in inspect.getmembers(module):
if inspect.isfunction(obj) and hasattr(obj, "_pare_register"):
if callable(obj) and hasattr(obj, "_pare_register"):
try:
service_registration = cast(
ServiceRegistration,
Expand Down
10 changes: 10 additions & 0 deletions pkg/pare/sdk/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def invoke_endpoint(function_name: str, arguments: RemoteInvocationArguments) ->
)
response.raise_for_status()
json_response = response.json()
json_status = json_response.get("status", 500)
if json_status != 200:
raise errors.PareInvokeError(
f"Function invocation for '{function_name}' failed with status: {json_status}. Detail: {json_response.get('detail', '[No detail provided]')}"
)
return json_response.get("result")
except requests.HTTPError as e:
raise errors.PareInvokeError(
Expand All @@ -51,6 +56,11 @@ async def async_invoke_endpoint(
) as response:
response.raise_for_status()
json_response = await response.json()
json_status = json_response.get("status", 500)
if json_status != 200:
raise errors.PareInvokeError(
f"Function invocation for '{function_name}' failed with status: {json_status}. Detail: {json_response.get('detail', '[No detail provided]')}"
)
return json_response.get("result")
except aiohttp.ClientResponseError as e:
raise errors.PareInvokeError(
Expand Down

0 comments on commit 9f85faa

Please sign in to comment.