{"record":{"id":"94681738954d1a14","repo":"ruvnet/RuView","slug":"workers-must-be-at-least-1","errorCode":null,"errorMessage":"Workers must be at least 1","messagePattern":"Workers must be at least 1","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/config/settings.py","lineNumber":223,"sourceCode":"        \"\"\"Validate streaming FPS.\"\"\"\n        if not 1 <= v <= 60:\n            raise ValueError(\"Stream FPS must be between 1 and 60\")\n        return v\n    \n    @field_validator(\"port\")\n    @classmethod\n    def validate_port(cls, v):\n        \"\"\"Validate port number.\"\"\"\n        if not 1 <= v <= 65535:\n            raise ValueError(\"Port must be between 1 and 65535\")\n        return v\n    \n    @field_validator(\"workers\")\n    @classmethod\n    def validate_workers(cls, v):\n        \"\"\"Validate worker count.\"\"\"\n        if v < 1:\n            raise ValueError(\"Workers must be at least 1\")\n        return v\n    \n    @field_validator(\"db_port\")\n    @classmethod\n    def validate_db_port(cls, v):\n        \"\"\"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    ","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/config/settings.py#L205-L241","documentation":"Pydantic v2 @field_validator on Settings.workers in archive/v1/src/config/settings.py. It enforces workers >= 1; zero and negative values raise ValueError at Settings() construction. Zero-worker configs are usually accidental rather than intentional — most often a computed value that evaluated to 0 on a small host.","triggerScenarios":"WORKERS=0 set to 'disable background workers'; WORKERS computed as os.cpu_count() - 1 on a single-core host (0); WORKERS=-1 from an auto-scaling formula; WORKERS copied from a memory-constrained template that assumes division floors to at least 1.","commonSituations":"Deployment scripts deriving worker counts from CPU counts on small containers (1 vCPU); CI runners with 1 core; attempts to serialize processing by setting workers to zero instead of one.","solutions":["Set WORKERS to at least 1; use 1 to force serial processing","Fix computed values with a floor: max(1, os.cpu_count() - 1)","Audit deployment templates for WORKERS formulas that can evaluate to 0 on single-core instances","If you truly want no background workers, gate the feature elsewhere — this setting requires >= 1"],"exampleFix":"# before\nWORKERS=0\n\n# after\nWORKERS=1","handlingStrategy":"validation","validationCode":"raw = int(os.environ.get(\"WORKERS\", \"4\"))\nassert raw >= 1, f\"WORKERS must be >= 1, got {raw} (use 1 for serial processing; os.cpu_count()-1 yields 0 on single-core hosts)\"","typeGuard":"def is_valid_worker_count(v) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and v >= 1","tryCatchPattern":"from pydantic import ValidationError\ntry:\n    settings = Settings()\nexcept ValidationError as e:\n    if any(err[\"loc\"][-1] == \"workers\" for err in e.errors()):\n        raise SystemExit(\"workers must be at least 1; use max(1, cpu_count - 1) in derived configs\") from e\n    raise","preventionTips":["Floor computed worker counts: max(1, os.cpu_count() - 1)","Test deployment templates on single-vCPU environments in CI","Use WORKERS=1 to serialize processing; zero is not a valid 'off' switch here"],"tags":["pydantic","settings","validation","workers","scaling","environment-variables","python"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}