Skip to content

Commit 8035170

Browse files
Yuri ZmytrakovYuri Zmytrakov
authored andcommitted
fix: ensure max_connection can accept None, Null, empty string
1 parent 983fedd commit 8035170

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

stac_fastapi/core/stac_fastapi/core/redis_utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ def validate_db_sentinel(cls, v: int) -> int:
3636
raise ValueError("REDIS_DB must be a positive integer")
3737
return v
3838

39+
@field_validator("REDIS_MAX_CONNECTIONS", mode="before")
40+
@classmethod
41+
def validate_max_connections(cls, v):
42+
"""Handle empty/None values for REDIS_MAX_CONNECTIONS."""
43+
if v in ["", "null", "Null", "NULL", "none", "None", "NONE", None]:
44+
return None
45+
return v
46+
3947
@field_validator("REDIS_SELF_LINK_TTL")
4048
@classmethod
4149
def validate_self_link_ttl_sentinel(cls, v: int) -> int:
@@ -118,6 +126,14 @@ def validate_db_standalone(cls, v: int) -> int:
118126
raise ValueError("REDIS_DB must be a positive integer")
119127
return v
120128

129+
@field_validator("REDIS_MAX_CONNECTIONS", mode="before")
130+
@classmethod
131+
def validate_max_connections(cls, v):
132+
"""Handle empty/None values for REDIS_MAX_CONNECTIONS."""
133+
if v in ["", "null", "Null", "NULL", "none", "None", "NONE", None]:
134+
return None
135+
return v
136+
121137
@field_validator("REDIS_SELF_LINK_TTL")
122138
@classmethod
123139
def validate_self_link_ttl_standalone(cls, v: int) -> int:

0 commit comments

Comments
 (0)