{"record":{"id":"4532c7bef6c2de5b","repo":"HKUDS/Vibe-Trading","slug":"yaml-config-is-not-available-because-pyyaml-is-mis","errorCode":null,"errorMessage":"YAML config is not available because PyYAML is missing","messagePattern":"YAML config is not available because PyYAML is missing","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/config/loader.py","lineNumber":252,"sourceCode":"\n    Args:\n        path: Config file path to decode.\n\n    Returns:\n        The decoded config object as a dictionary.\n\n    Raises:\n        ValueError: If the file format is unsupported, YAML support is\n            unavailable, or the decoded payload is not an object.\n    \"\"\"\n    suffix = path.suffix.lower()\n    text = path.read_text(encoding=\"utf-8\")\n\n    if suffix == \".json\":\n        data = json.loads(text)\n    elif suffix in {\".yaml\", \".yml\"}:\n        if yaml is None:\n            raise ValueError(\"YAML config is not available because PyYAML is missing\")\n        data = yaml.safe_load(text) or {}\n    else:\n        raise ValueError(f\"Unsupported config file format: {suffix or '<none>'}\")\n\n    if not isinstance(data, dict):\n        raise ValueError(\"Agent config must decode to a JSON/YAML object\")\n    return data\n\n\ndef _merge_agent_config_dicts(base: dict[str, Any], override: dict[str, Any]) -> dict[str, Any]:\n    \"\"\"Merge top-level agent config payloads with MCP-aware server replacement.\"\"\"\n    non_mcp_override = {key: value for key, value in override.items() if key != \"mcp_servers\"}\n    merged = _merge_dicts(base, non_mcp_override)\n\n    override_servers = override.get(\"mcp_servers\")\n    if not isinstance(override_servers, dict):\n        if \"mcp_servers\" in override:\n            merged[\"mcp_servers\"] = override_servers","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/config/loader.py#L234-L270","documentation":"Raised by _read_config_file when a .yaml/.yml config is requested but the yaml module imported to None, meaning PyYAML is not installed in the environment. The loader supports JSON out of the box; YAML is an optional capability.","triggerScenarios":"Calling load_agent_config with a path ending in .yaml or .yml in an environment without PyYAML installed.","commonSituations":"Base install without the yaml extra; CI environments trimmed of optional deps; config authored as YAML but deployed to a runtime that only installed core dependencies.","solutions":["pip install pyyaml (or the project's yaml/config extra if one exists).","Alternatively convert the config to .json, which needs no extra dependency."],"exampleFix":"# before\npip install vibe-trading-ai  # no pyyaml\n\n# after\npip install pyyaml vibe-trading-ai","handlingStrategy":"validation","validationCode":"def can_read_yaml_config() -> bool:\n    import importlib.util\n    return importlib.util.find_spec('yaml') is not None","typeGuard":null,"tryCatchPattern":"try:\n    cfg = load_agent_config(path)\nexcept ValueError as e:\n    if 'PyYAML is missing' in str(e):\n        cfg = load_agent_config(json_equivalent_path)","preventionTips":["Install PyYAML in every environment that touches YAML configs","Prefer .json configs for minimal deployment targets","Add a startup probe for optional deps"],"tags":["config","yaml","dependencies","optional-dependency"],"backgroundTag":"missing-optional-dependency","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}