From 457b171eb1b6ee7e4370f8e98118980c350c440a Mon Sep 17 00:00:00 2001 From: Aaron Harper Date: Fri, 13 Sep 2024 09:45:52 -0400 Subject: [PATCH] Fix inspection type --- inngest/_internal/comm_lib/handler.py | 5 ++++- inngest/_internal/server_lib/inspection.py | 13 ++++++++++--- inngest/_internal/server_lib/registration.py | 8 ++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/inngest/_internal/comm_lib/handler.py b/inngest/_internal/comm_lib/handler.py index 8652a8c3..c5c8f92d 100644 --- a/inngest/_internal/comm_lib/handler.py +++ b/inngest/_internal/comm_lib/handler.py @@ -471,7 +471,7 @@ def _build_inspection_response( signing_key_hash=signing_key_hash, ) - authentication_succeeded = None + authentication_succeeded: typing.Optional[typing.Literal[False]] = None if isinstance(request_signing_key, Exception): authentication_succeeded = False @@ -518,6 +518,9 @@ def in_band( ) if isinstance(inspection, Exception): return inspection + if isinstance(inspection, server_lib.UnauthenticatedInspection): + # Unreachable + return Exception("request must be signed for in-band sync") res_body = server_lib.InBandSynchronizeResponse( app_id=handler._client.app_id, diff --git a/inngest/_internal/server_lib/inspection.py b/inngest/_internal/server_lib/inspection.py index 33b4a72a..1d54306a 100644 --- a/inngest/_internal/server_lib/inspection.py +++ b/inngest/_internal/server_lib/inspection.py @@ -13,7 +13,7 @@ class Capabilities(types.BaseModel): class UnauthenticatedInspection(types.BaseModel): schema_version: str = "2024-05-24" - authentication_succeeded: typing.Optional[bool] + authentication_succeeded: typing.Optional[typing.Literal[False]] function_count: int has_event_key: bool has_signing_key: bool @@ -21,15 +21,22 @@ class UnauthenticatedInspection(types.BaseModel): mode: ServerKind -class AuthenticatedInspection(UnauthenticatedInspection): +class AuthenticatedInspection(types.BaseModel): + schema_version: str = "2024-05-24" + api_origin: str app_id: str - authentication_succeeded: bool = True + authentication_succeeded: typing.Literal[True] = True capabilities: Capabilities = Capabilities() env: typing.Optional[str] event_api_origin: str event_key_hash: typing.Optional[str] framework: str + function_count: int + has_event_key: bool + has_signing_key: bool + has_signing_key_fallback: bool + mode: ServerKind sdk_language: str = const.LANGUAGE sdk_version: str = const.VERSION serve_origin: typing.Optional[str] diff --git a/inngest/_internal/server_lib/registration.py b/inngest/_internal/server_lib/registration.py index 155ab3f4..63b86897 100644 --- a/inngest/_internal/server_lib/registration.py +++ b/inngest/_internal/server_lib/registration.py @@ -8,11 +8,7 @@ from inngest._internal import const, errors, transforms, types from .consts import DeployType, Framework -from .inspection import ( - AuthenticatedInspection, - Capabilities, - UnauthenticatedInspection, -) +from .inspection import AuthenticatedInspection, Capabilities class _BaseConfig(types.BaseModel): @@ -189,7 +185,7 @@ class InBandSynchronizeResponse(types.BaseModel): env: typing.Optional[str] framework: Framework functions: list[FunctionConfig] - inspection: typing.Union[AuthenticatedInspection, UnauthenticatedInspection] + inspection: AuthenticatedInspection platform: typing.Optional[str] sdk_author: str = const.AUTHOR sdk_language: str = const.LANGUAGE