Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions stac_fastapi/core/stac_fastapi/core/redis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down