ruvnet/RuView · error · ValueError
Database pool size must be at least 1
Error message
Database pool size must be at least 1
What it means
Raised by the Pydantic field_validator validate_db_pool_size on Settings in archive/v1/src/config/settings.py. db_pool_size (default 10) must be at least 1; passing 0 or a negative value raises ValueError, wrapped into a ValidationError during Settings construction. The guard exists because SQLAlchemy pools with zero connections cannot serve any request.
Source
Thrown at archive/v1/src/config/settings.py:247
"""Validate database port."""
if not 1 <= v <= 65535:
raise ValueError("Database port must be between 1 and 65535")
return v
@field_validator("redis_port")
@classmethod
def validate_redis_port(cls, v):
"""Validate Redis port."""
if not 1 <= v <= 65535:
raise ValueError("Redis port must be between 1 and 65535")
return v
@field_validator("db_pool_size")
@classmethod
def validate_db_pool_size(cls, v):
"""Validate database pool size."""
if v < 1:
raise ValueError("Database pool size must be at least 1")
return v
@field_validator("monitoring_interval_seconds", "cleanup_interval_seconds", "backup_interval_seconds")
@classmethod
def validate_interval_seconds(cls, v):
"""Validate interval settings."""
if v < 0:
raise ValueError("Interval seconds must be non-negative")
return v
@property
def is_development(self) -> bool:
"""Check if running in development environment."""
return self.environment == "development"
@property
def is_production(self) -> bool:
"""Check if running in production environment."""
return self.environment == "production"View on GitHub (pinned to 4685618388)
Solutions
- Set DB_POOL_SIZE to at least 1 (e.g. 5 for small deployments, 10 default for production).
- To reduce DB load, lower the pool size but keep it >=1, and tune pool_recycle/pool_pre_ping instead of zeroing the pool.
- Check `.env`/compose/Helm values for arithmetic that can produce 0 and clamp it: `max(1, int(os.environ.get('DB_POOL_SIZE', 10)))` before it reaches Settings.
- In tests, use 1 (minimum valid) when you want a single connection.
Example fix
# before DB_POOL_SIZE=0 # after DB_POOL_SIZE=5 # pooling cannot be disabled; 1 is the minimum
Defensive patterns
Strategy: validation
Validate before calling
import os
pool = int(os.environ.get('DB_POOL_SIZE', '10'))
if pool < 1:
pool = 1 # clamp, or fail loudly:
# raise SystemExit('DB_POOL_SIZE must be >= 1')
os.environ['DB_POOL_SIZE'] = str(pool) Try / catch
from pydantic import ValidationError
try:
settings = Settings()
except ValidationError as e:
if any('db_pool_size' in err['loc'] for err in e.errors()):
raise SystemExit('DB_POOL_SIZE must be >= 1; pooling cannot be disabled') Prevention
- Never use 0 to disable pooling; use pool_pre_ping and small pool sizes to debug leaks.
- Clamp computed pool sizes with max(1, value).
- Set DB_POOL_SIZE explicitly in every environment template so defaults never surprise you.
When it happens
Trigger: Building the Settings object with DB_POOL_SIZE=0 or a negative number in the environment, or Settings(db_pool_size=0) in code/tests. Common when someone tries to disable pooling to debug connection leaks.
Common situations: Setting DB_POOL_SIZE=0 intending to turn pooling off (SQLAlchemy does not work that way); lowering the pool for memory-constrained containers and accidentally crossing to 0; generated config from Helm values or Terraform outputs that compute `replicas - 1` and hit 0; stale test fixtures using 0.
Related errors
- Database port must be between 1 and 65535
- Threshold must be between 0.0 and 1.0
- FPS must be between 1 and 60
- Compression level must be between 1 and 9
- Failed to load domain configuration: {e}
AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16).
Data as JSON: /api/errors/42143f7010f91241.
Report an issue: GitHub.