Skip to content
This repository was archived by the owner on Feb 20, 2025. It is now read-only.

Commit 618671a

Browse files
committed
fix: raise errors if no token set
1 parent baa8567 commit 618671a

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

hatchet_sdk/loader.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class ClientConfig(BaseModel):
8181
@classmethod
8282
def validate_token(cls, token: str) -> str:
8383
if not token:
84-
return ""
84+
raise ValueError("Token must be set")
8585

8686
return token
8787

@@ -100,7 +100,7 @@ def validate_tenant_id(cls, tenant_id: str, info: ValidationInfo) -> str:
100100

101101
if not tenant_id:
102102
if not token:
103-
return ""
103+
raise ValueError("Either the token or tenant_id must be set")
104104

105105
return get_tenant_id_from_jwt(token)
106106

@@ -109,10 +109,7 @@ def validate_tenant_id(cls, tenant_id: str, info: ValidationInfo) -> str:
109109
@field_validator("host_port", mode="after")
110110
@classmethod
111111
def validate_host_port(cls, host_port: str, info: ValidationInfo) -> str:
112-
token = cast(str | None, info.data.get("token"))
113-
114-
if not token:
115-
return host_port
112+
token = cast(str, info.data.get("token"))
116113

117114
_, grpc_broadcast_address = get_addresses_from_jwt(token)
118115

@@ -121,10 +118,7 @@ def validate_host_port(cls, host_port: str, info: ValidationInfo) -> str:
121118
@field_validator("server_url", mode="after")
122119
@classmethod
123120
def validate_server_url(cls, server_url: str, info: ValidationInfo) -> str:
124-
token = cast(str | None, info.data.get("token"))
125-
126-
if not token:
127-
return server_url
121+
token = cast(str, info.data.get("token"))
128122

129123
_server_url, _ = get_addresses_from_jwt(token)
130124

0 commit comments

Comments
 (0)