fix: allow empty CRAWL_LIMIT env value
This commit is contained in:
@@ -110,4 +110,4 @@ docker compose exec postgres pg_dump -U miem miem_workers > backup.sql
|
||||
docker compose down
|
||||
```
|
||||
|
||||
Версия сервиса: `0.2.6`. Админка всегда показывает версии backend и frontend в footer.
|
||||
Версия сервиса: `0.2.7`. Админка всегда показывает версии backend и frontend в footer.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from functools import lru_cache
|
||||
from pydantic import Field
|
||||
from pydantic import Field, field_validator
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
@@ -19,6 +19,13 @@ class Settings(BaseSettings):
|
||||
session_secret: str = Field(default="dev-session-secret", min_length=8)
|
||||
mcp_token: str = "dev-mcp-token"
|
||||
|
||||
@field_validator("crawl_limit", mode="before")
|
||||
@classmethod
|
||||
def empty_crawl_limit_as_none(cls, value):
|
||||
if value == "":
|
||||
return None
|
||||
return value
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_settings() -> Settings:
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
APP_VERSION = "0.2.6"
|
||||
FRONTEND_VERSION = "0.2.6"
|
||||
BACKEND_VERSION = "0.2.6"
|
||||
APP_VERSION = "0.2.7"
|
||||
FRONTEND_VERSION = "0.2.7"
|
||||
BACKEND_VERSION = "0.2.7"
|
||||
|
||||
@@ -18,7 +18,7 @@ def test_health_returns_versions():
|
||||
response = client.get("/api/health")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json()["backend_version"] == "0.2.6"
|
||||
assert response.json()["backend_version"] == "0.2.7"
|
||||
|
||||
|
||||
def test_mcp_requires_token_and_lists_tools():
|
||||
|
||||
13
tests/test_config.py
Normal file
13
tests/test_config.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from app.config import Settings
|
||||
|
||||
|
||||
def test_empty_crawl_limit_is_treated_as_none():
|
||||
settings = Settings(crawl_limit="")
|
||||
|
||||
assert settings.crawl_limit is None
|
||||
|
||||
|
||||
def test_numeric_crawl_limit_is_parsed():
|
||||
settings = Settings(crawl_limit="25")
|
||||
|
||||
assert settings.crawl_limit == 25
|
||||
Reference in New Issue
Block a user