{"record":{"id":"93b6a46397d06d4c","repo":"ruvnet/RuView","slug":"failed-to-load-domain-configuration-e","errorCode":null,"errorMessage":"Failed to load domain configuration: {e}","messagePattern":"Failed to load domain configuration: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/config/domains.py","lineNumber":468,"sourceCode":"        for router_data in data.get(\"routers\", []):\n            router = RouterConfig(**router_data)\n            config.add_router(router)\n        \n        # Load pose models\n        for model_data in data.get(\"pose_models\", []):\n            model = PoseModelConfig(**model_data)\n            config.add_pose_model(model)\n        \n        # Load streaming config\n        if \"streaming\" in data:\n            config.streaming = StreamingConfig(**data[\"streaming\"])\n        \n        # Load alerts config\n        if \"alerts\" in data:\n            config.alerts = AlertConfig(**data[\"alerts\"])\n    \n    except Exception as e:\n        raise ValueError(f\"Failed to load domain configuration: {e}\")\n    \n    return config\n\n\ndef save_domain_config_to_file(config: DomainConfig, file_path: str):\n    \"\"\"Save domain configuration to file.\"\"\"\n    import json\n    \n    try:\n        with open(file_path, 'w') as f:\n            json.dump(config.to_dict(), f, indent=2)\n    except Exception as e:\n        raise ValueError(f\"Failed to save domain configuration: {e}\")","sourceCodeStart":450,"sourceCodeEnd":481,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/config/domains.py#L450-L481","documentation":"Wrapper exception in load-domain-config in archive/v1/src/config/domains.py. The loader reads a file, parses it, and constructs the config models; any exception anywhere in that chain — missing file (FileNotFoundError), invalid JSON/YAML syntax, nested pydantic ValidationError from the domain validators, key errors on malformed sections — is re-raised as ValueError('Failed to load domain configuration: {e}') with the original error chained in the message.","triggerScenarios":"load_domain_config_from_file on a nonexistent path; a config file with a JSON syntax error; the 'pose_models'/'streaming'/'alerts' sections containing values that fail the field validators (e.g., thresholds out of range); required keys missing so construction raises KeyError/TypeError.","commonSituations":"Deploying with a config path that differs from the documented location; hand-edited config files with trailing commas or comments in strict JSON; upgrading the schema so old config files no longer validate; CI loading a template file with placeholder values.","solutions":["Read the tail of the message after 'Failed to load domain configuration:' — it names the actual failure (file error vs parse error vs validation error)","If it is a nested pydantic ValidationError, fix the specific field it lists (e.g., threshold ranges)","Validate the file parses standalone (python -c \"import json; json.load(open(path))\") before blaming the loader","Confirm the path exists and is readable at the exact location the loader is given"],"exampleFix":"# before\nconfig = load_domain_config_from_file(\"config/domains.json\")\n\n# after (fail with the real cause, not the wrapper)\ntry:\n    config = load_domain_config_from_file(\"config/domains.json\")\nexcept ValueError as e:\n    raise SystemExit(f\"config load failed: {e}\") from e.__cause__ or e","handlingStrategy":"try-catch","validationCode":"import json, os\n\npath = \"config/domains.json\"\nassert os.path.isfile(path) and os.access(path, os.R_OK), f\"config not readable: {path}\"\njson.load(open(path))  # parse errors surface here with clean messages","typeGuard":"def config_file_loadable(path: str) -> bool:\n    try:\n        with open(path) as f:\n            json.load(f)\n        return True\n    except (OSError, ValueError):\n        return False","tryCatchPattern":"try:\n    config = load_domain_config_from_file(path)\nexcept ValueError as e:\n    # the real cause is chained after 'Failed to load domain configuration:'\n    raise SystemExit(f\"cannot load domain config: {e}\") from None","preventionTips":["Validate the file exists and parses as JSON before invoking the loader","Keep example/template configs out of the production load path","Run the loader in CI against all shipped configs so schema drift fails the build, not the deploy"],"tags":["pydantic","config","io","json","validation","python"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}