{"record":{"id":"42143f7010f91241","repo":"ruvnet/RuView","slug":"database-pool-size-must-be-at-least-1","errorCode":null,"errorMessage":"Database pool size must be at least 1","messagePattern":"Database pool size must be at least 1","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/config/settings.py","lineNumber":247,"sourceCode":"        \"\"\"Validate database port.\"\"\"\n        if not 1 <= v <= 65535:\n            raise ValueError(\"Database port must be between 1 and 65535\")\n        return v\n    \n    @field_validator(\"redis_port\")\n    @classmethod\n    def validate_redis_port(cls, v):\n        \"\"\"Validate Redis port.\"\"\"\n        if not 1 <= v <= 65535:\n            raise ValueError(\"Redis port must be between 1 and 65535\")\n        return v\n    \n    @field_validator(\"db_pool_size\")\n    @classmethod\n    def validate_db_pool_size(cls, v):\n        \"\"\"Validate database pool size.\"\"\"\n        if v < 1:\n            raise ValueError(\"Database pool size must be at least 1\")\n        return v\n    \n    @field_validator(\"monitoring_interval_seconds\", \"cleanup_interval_seconds\", \"backup_interval_seconds\")\n    @classmethod\n    def validate_interval_seconds(cls, v):\n        \"\"\"Validate interval settings.\"\"\"\n        if v < 0:\n            raise ValueError(\"Interval seconds must be non-negative\")\n        return v\n    @property\n    def is_development(self) -> bool:\n        \"\"\"Check if running in development environment.\"\"\"\n        return self.environment == \"development\"\n    \n    @property\n    def is_production(self) -> bool:\n        \"\"\"Check if running in production environment.\"\"\"\n        return self.environment == \"production\"","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/config/settings.py#L229-L265","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nDB_POOL_SIZE=0\n\n# after\nDB_POOL_SIZE=5   # pooling cannot be disabled; 1 is the minimum","handlingStrategy":"validation","validationCode":"import os\n\npool = int(os.environ.get('DB_POOL_SIZE', '10'))\nif pool < 1:\n    pool = 1  # clamp, or fail loudly:\n    # raise SystemExit('DB_POOL_SIZE must be >= 1')\nos.environ['DB_POOL_SIZE'] = str(pool)","typeGuard":null,"tryCatchPattern":"from pydantic import ValidationError\n\ntry:\n    settings = Settings()\nexcept ValidationError as e:\n    if any('db_pool_size' in err['loc'] for err in e.errors()):\n        raise SystemExit('DB_POOL_SIZE must be >= 1; pooling cannot be disabled')","preventionTips":["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."],"tags":["config","pydantic","database","connection-pool","validation"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}