{"record":{"id":"e3ba7bf808e0cd3d","repo":"ruvnet/RuView","slug":"interval-seconds-must-be-non-negative","errorCode":null,"errorMessage":"Interval seconds must be non-negative","messagePattern":"Interval seconds must be non-negative","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/config/settings.py","lineNumber":255,"sourceCode":"        \"\"\"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\"\n    \n    @property\n    def is_testing(self) -> bool:\n        \"\"\"Check if running in testing environment.\"\"\"\n        return self.environment == \"testing\"\n    \n    def get_database_url(self) -> str:\n        \"\"\"Get database URL with fallback.\"\"\"","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/config/settings.py#L237-L273","documentation":"Raised by the shared Pydantic field_validator validate_interval_seconds in archive/v1/src/config/settings.py. It applies to three fields at once: monitoring_interval_seconds (default 60), cleanup_interval_seconds (default 3600), and backup_interval_seconds (default 86400). Any of them set below 0 raises ValueError at Settings instantiation; 0 itself is allowed (means the task is disabled).","triggerScenarios":"Setting MONITORING_INTERVAL_SECONDS, CLEANUP_INTERVAL_SECONDS, or BACKUP_INTERVAL_SECONDS to a negative number in the environment before creating the Settings object. All three validators run even if only one interval is misconfigured, and the error message does not say which field triggered it.","commonSituations":"Using -1 as a convention for disabled tasks; template math like `60 * -1` or `${interval:-60}` typos producing negative values; Kubernetes ConfigMap values pasted with a stray minus sign; using seconds where minutes were intended (e.g. -0.5 from a unit-conversion script).","solutions":["Set the offending interval to 0 to disable that task, or to a positive number of seconds.","Identify which of the three env vars is negative: inspect MONITORING_INTERVAL_SECONDS, CLEANUPING_INTERVAL_SECONDS-style spellings, and BACKUP_INTERVAL_SECONDS in the environment (note the message does not name the field, so check all three).","Sanitize computed values before they reach Settings: `value = max(0, computed_interval)`.","If you use -1 as a disable flag, translate it to 0 at the config layer: `interval if interval > 0 else 0`."],"exampleFix":"# before\nCLEANUP_INTERVAL_SECONDS=-1\n\n# after\nCLEANUP_INTERVAL_SECONDS=0   # 0 disables the task; negatives are rejected","handlingStrategy":"validation","validationCode":"INTERVAL_VARS = ('MONITORING_INTERVAL_SECONDS', 'CLEANUP_INTERVAL_SECONDS', 'BACKUP_INTERVAL_SECONDS')\n\nfor var in INTERVAL_VARS:\n    if var in os.environ:\n        val = int(os.environ[var])\n        if val < 0:\n            raise SystemExit(f'{var}={val} is negative; use 0 to disable the task')","typeGuard":null,"tryCatchPattern":"from pydantic import ValidationError\n\ntry:\n    settings = Settings()\nexcept ValidationError as e:\n    if any('interval_seconds' in ''.join(map(str, err['loc'])) for err in e.errors()):\n        print('One of MONITORING/CLEANUP/BACKUP_INTERVAL_SECONDS is negative; 0 disables')\n        raise","preventionTips":["Use 0 (not -1) as the disable convention for all three interval vars.","Lint env files for negative numbers anywhere.","When intervals are computed, clamp to max(0, value) at the boundary."],"tags":["config","pydantic","scheduled-tasks","validation","env-vars"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}