{"record":{"id":"2e7f004343acebf7","repo":"ruvnet/RuView","slug":"log-level-must-be-one-of-allowed-levels","errorCode":null,"errorMessage":"Log level must be one of: {allowed_levels}","messagePattern":"Log level must be one of: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/config/settings.py","lineNumber":191,"sourceCode":"        extra=\"ignore\",\n    )\n    \n    @field_validator(\"environment\")\n    @classmethod\n    def validate_environment(cls, v):\n        \"\"\"Validate environment setting.\"\"\"\n        allowed_environments = [\"development\", \"staging\", \"production\"]\n        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    ","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/config/settings.py#L173-L209","documentation":"Pydantic v2 @field_validator on Settings.log_level in archive/v1/src/config/settings.py. It uppercases the input and enforces membership in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']. The check is case-insensitive (v.upper()), but aliases are not supported: 'TRACE', 'NOTICE', 'VERBOSE', and notably 'WARN' — a legal alias in Python's own logging module — are all rejected with this ValueError at Settings() construction.","triggerScenarios":"LOG_LEVEL=WARN (legal in logging.basicConfig but rejected here); LOG_LEVEL=TRACE or VERBOSE from structured-logging conventions; LOG_LEVEL=notice; lowercase 'debug' works (uppercased), but any non-standard name fails.","commonSituations":"Copying LOG_LEVEL=WARN from systemd or logging tutorials; switching from loguru (TRACE) back to stdlib settings; operators shortening WARNING to WARN in .env files.","solutions":["Use the full standard names: DEBUG, INFO, WARNING, ERROR, or CRITICAL (case does not matter)","Replace WARN with WARNING everywhere (docker-compose, .env, k8s env blocks)","Map exotic levels at the source: TRACE->DEBUG, NOTICE->INFO","Add a startup config check in CI to catch bad LOG_LEVEL values before deploy"],"exampleFix":"# before\nLOG_LEVEL=WARN\n\n# after\nLOG_LEVEL=WARNING","handlingStrategy":"validation","validationCode":"ALLOWED = {\"DEBUG\", \"INFO\", \"WARNING\", \"ERROR\", \"CRITICAL\"}\nraw = os.environ.get(\"LOG_LEVEL\", \"INFO\").strip().upper()\nnormalized = {\"WARN\": \"WARNING\", \"TRACE\": \"DEBUG\", \"VERBOSE\": \"DEBUG\", \"NOTICE\": \"INFO\"}.get(raw, raw)\nassert normalized in ALLOWED, f\"LOG_LEVEL must be one of {sorted(ALLOWED)}, got {raw!r}\"","typeGuard":"def is_valid_log_level(v: str) -> bool:\n    return v.strip().upper() in {\"DEBUG\", \"INFO\", \"WARNING\", \"ERROR\", \"CRITICAL\"}","tryCatchPattern":"from pydantic import ValidationError\ntry:\n    settings = Settings()\nexcept ValidationError as e:\n    if any(err[\"loc\"][-1] == \"log_level\" for err in e.errors()):\n        raise SystemExit(\"LOG_LEVEL: use DEBUG|INFO|WARNING|ERROR|CRITICAL (WARN alias is rejected)\") from e\n    raise","preventionTips":["Replace WARN with WARNING everywhere — the validator does not accept the stdlib alias","Map non-stdlib levels (TRACE, NOTICE) to their nearest allowed value at the source","Centralize logging config in one template so aliases cannot leak in from copy-paste"],"tags":["pydantic","settings","logging","environment-variables","validation","python"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}