From 8035170d7302699978a33e2318faaa1a78c0f797 Mon Sep 17 00:00:00 2001 From: Yuri Zmytrakov Date: Sun, 2 Nov 2025 19:38:58 +0100 Subject: [PATCH 1/2] fix: ensure max_connection can accept None, Null, empty string --- .../core/stac_fastapi/core/redis_utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/stac_fastapi/core/stac_fastapi/core/redis_utils.py b/stac_fastapi/core/stac_fastapi/core/redis_utils.py index 6cfc00b6b..f1e3fe74f 100644 --- a/stac_fastapi/core/stac_fastapi/core/redis_utils.py +++ b/stac_fastapi/core/stac_fastapi/core/redis_utils.py @@ -36,6 +36,14 @@ def validate_db_sentinel(cls, v: int) -> int: raise ValueError("REDIS_DB must be a positive integer") return v + @field_validator("REDIS_MAX_CONNECTIONS", mode="before") + @classmethod + def validate_max_connections(cls, v): + """Handle empty/None values for REDIS_MAX_CONNECTIONS.""" + if v in ["", "null", "Null", "NULL", "none", "None", "NONE", None]: + return None + return v + @field_validator("REDIS_SELF_LINK_TTL") @classmethod def validate_self_link_ttl_sentinel(cls, v: int) -> int: @@ -118,6 +126,14 @@ def validate_db_standalone(cls, v: int) -> int: raise ValueError("REDIS_DB must be a positive integer") return v + @field_validator("REDIS_MAX_CONNECTIONS", mode="before") + @classmethod + def validate_max_connections(cls, v): + """Handle empty/None values for REDIS_MAX_CONNECTIONS.""" + if v in ["", "null", "Null", "NULL", "none", "None", "NONE", None]: + return None + return v + @field_validator("REDIS_SELF_LINK_TTL") @classmethod def validate_self_link_ttl_standalone(cls, v: int) -> int: From f2a500c133640e22f1e50dda42ad0f09db197e66 Mon Sep 17 00:00:00 2001 From: Yuri Zmytrakov Date: Tue, 4 Nov 2025 10:49:05 +0100 Subject: [PATCH 2/2] docs: changelog for redis_max_connections validation --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28711b3b4..abf796876 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added +- Added validator for `REDIS_MAX_CONNECTIONS` to handle empty or null-like values ("", "null", None) and return None instead. [#519](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/519) + ### Changed ### Fixed