Skip to content

Commit

Permalink
Fix inspection type
Browse files Browse the repository at this point in the history
  • Loading branch information
amh4r committed Sep 13, 2024
1 parent be53715 commit 457b171
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
5 changes: 4 additions & 1 deletion inngest/_internal/comm_lib/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
13 changes: 10 additions & 3 deletions inngest/_internal/server_lib/inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,30 @@ 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
has_signing_key_fallback: bool
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]
Expand Down
8 changes: 2 additions & 6 deletions inngest/_internal/server_lib/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 457b171

Please sign in to comment.