{"record":{"id":"bcb1d4106ec1e8f6","repo":"ruvnet/RuView","slug":"confidence-threshold-must-be-between-0-0-and-1-0","errorCode":null,"errorMessage":"Confidence threshold must be between 0.0 and 1.0","messagePattern":"Confidence threshold must be between 0\\.0 and 1\\.0","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/config/settings.py","lineNumber":199,"sourceCode":"        if v not in allowed_environments:\n            raise ValueError(f\"Environment must be one of: {allowed_environments}\")\n        return v\n    \n    @field_validator(\"log_level\")\n    @classmethod\n    def validate_log_level(cls, v):\n        \"\"\"Validate log level setting.\"\"\"\n        allowed_levels = [\"DEBUG\", \"INFO\", \"WARNING\", \"ERROR\", \"CRITICAL\"]\n        if v.upper() not in allowed_levels:\n            raise ValueError(f\"Log level must be one of: {allowed_levels}\")\n        return v.upper()\n    \n    @field_validator(\"pose_confidence_threshold\")\n    @classmethod\n    def validate_confidence_threshold(cls, v):\n        \"\"\"Validate confidence threshold.\"\"\"\n        if not 0.0 <= v <= 1.0:\n            raise ValueError(\"Confidence threshold must be between 0.0 and 1.0\")\n        return v\n    \n    @field_validator(\"stream_fps\")\n    @classmethod\n    def validate_stream_fps(cls, v):\n        \"\"\"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    ","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/config/settings.py#L181-L217","documentation":"Pydantic v2 @field_validator on Settings.pose_confidence_threshold in archive/v1/src/config/settings.py. It enforces 0.0 <= value <= 1.0; values outside that range raise ValueError when Settings is constructed, aborting startup. Like the domain-level threshold validator, this expects a fraction — percentage conventions (0-100) are the most common cause of failure.","triggerScenarios":"POSE_CONFIDENCE_THRESHOLD=85 (percentage convention); =-1 attempting to disable filtering; =1.5 during tuning to 'see everything'; =0.0..1.0 works, so anything outside indicates a unit or typo problem.","commonSituations":"Env files authored with percentages; values copied from tools that use 0-100 scales; tuning experiments that push the bound past 1.0.","solutions":["Set POSE_CONFIDENCE_THRESHOLD to a fraction in [0.0, 1.0] (85% -> 0.85)","To disable confidence filtering, use 0.0 rather than a negative value","Clamp operator-supplied values before they reach Settings if the input source is untrusted","Keep the fraction convention documented in the .env template"],"exampleFix":"# before\nPOSE_CONFIDENCE_THRESHOLD=85\n\n# after\nPOSE_CONFIDENCE_THRESHOLD=0.85","handlingStrategy":"validation","validationCode":"raw = float(os.environ.get(\"POSE_CONFIDENCE_THRESHOLD\", \"0.5\"))\nassert 0.0 <= raw <= 1.0, f\"POSE_CONFIDENCE_THRESHOLD must be a fraction in [0,1], got {raw} (did you mean {raw / 100}?)\"","typeGuard":"def is_unit_fraction(v) -> bool:\n    return isinstance(v, (int, float)) and not isinstance(v, bool) and 0.0 <= float(v) <= 1.0","tryCatchPattern":"from pydantic import ValidationError\ntry:\n    settings = Settings()\nexcept ValidationError as e:\n    if any(err[\"loc\"][-1] == \"pose_confidence_threshold\" for err in e.errors()):\n        raise SystemExit(\"pose_confidence_threshold must be 0.0-1.0 (fractions, not percentages)\") from e\n    raise","preventionTips":["Store thresholds as fractions in env files; document that 0.85 means 85%","Sanity-check magnitude: values > 1 almost always mean a percentage slipped in","Clamp operator input before it reaches Settings when the source is untrusted"],"tags":["pydantic","settings","validation","threshold","environment-variables","python"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}