{"record":{"id":"9257b96b3f19eb3f","repo":"ruvnet/RuView","slug":"redis-port-must-be-between-1-and-65535","errorCode":null,"errorMessage":"Redis port must be between 1 and 65535","messagePattern":"Redis port must be between 1 and 65535","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/config/settings.py","lineNumber":239,"sourceCode":"        \"\"\"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    \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","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/config/settings.py#L221-L257","documentation":"Raised by the Pydantic field_validator validate_redis_port on the Settings model in archive/v1/src/config/settings.py. Any redis_port (default 6379) outside 1..65535 makes the ValueError surface as a Pydantic ValidationError when the Settings object is built, before any Redis client is created. This mirrors the db_port check and guarantees only connectable ports are passed to get_redis_url().","triggerScenarios":"Instantiating Settings with redis_port set to 0, negative, or >65535, most commonly via the REDIS_PORT environment variable. The validator runs even when redis_enabled is false, so an invalid REDIS_PORT breaks startup regardless of whether Redis is used.","commonSituations":"Setting REDIS_PORT=0 to turn Redis off (use REDIS_ENABLED=false instead); docker-compose files that map ports like `6379:6379` but export the container-side ephemeral value; leftover REDIS_PORT from a different service (e.g. a Node dev server port 30000+ typo); values with whitespace or quotes causing odd coercion.","solutions":["Set REDIS_PORT to a valid port such as 6379 (or your actual Redis port).","If Redis is not used, disable it explicitly with REDIS_ENABLED=false rather than port 0 — note the validator still runs, so the port must be valid anyway.","Inspect `.env`, shell environment, and compose `environment:` blocks for REDIS_PORT overrides.","If Redis is addressed by URL, set redis_url directly and keep redis_port at its default."],"exampleFix":"# before\nREDIS_PORT=0          # intent: disable Redis\nREDIS_ENABLED=true\n\n# after\nREDIS_ENABLED=false   # correct way to disable\nREDIS_PORT=6379       # keep a valid port","handlingStrategy":"validation","validationCode":"import os\n\ndef valid_port(name: str, default: str) -> int:\n    value = int(os.environ.get(name, default))\n    assert 1 <= value <= 65535, f'{name}={value} out of range'\n    return value\n\nredis_port = valid_port('REDIS_PORT', '6379')","typeGuard":null,"tryCatchPattern":"from pydantic import ValidationError\n\ntry:\n    settings = Settings()\nexcept ValidationError as e:\n    bad = [err for err in e.errors() if 'redis_port' in err['loc']]\n    if bad:\n        os.environ['REDIS_PORT'] = '6379'  # corrective default\n        settings = Settings()","preventionTips":["Disable Redis with REDIS_ENABLED=false instead of port tricks.","Keep REDIS_PORT pinned to the compose service port in one place (an .env file checked into the template).","Document that the validator runs even when Redis is disabled."],"tags":["config","pydantic","redis","validation","env-vars"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}