Skip to content

Commit dd051b1

Browse files
committed
feat: add check for REDIS_MAX_CONNECTIONS
1 parent 801f8b6 commit dd051b1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

api/configs/middleware/cache/redis_config.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pydantic import Field, NonNegativeInt, PositiveFloat, PositiveInt
1+
from pydantic import Field, NonNegativeInt, PositiveFloat, PositiveInt, field_validator
22
from pydantic_settings import BaseSettings
33

44

@@ -116,3 +116,13 @@ class RedisConfig(BaseSettings):
116116
description="Maximum connections in the Redis connection pool (unset for library default)",
117117
default=None,
118118
)
119+
120+
@field_validator("REDIS_MAX_CONNECTIONS", mode="before")
121+
@classmethod
122+
def _empty_string_to_none_for_max_conns(cls, v):
123+
"""Allow empty string in env/.env to mean 'unset' (None)."""
124+
if v is None:
125+
return None
126+
if isinstance(v, str) and v.strip() == "":
127+
return None
128+
return v

0 commit comments

Comments
 (0)