{"record":{"id":"bfba2cbaedcf548c","repo":"langchain-ai/deepagents","slug":"configresolution-must-have-at-least-one-used-path","errorCode":null,"errorMessage":"ConfigResolution must have at least one used path","messagePattern":"ConfigResolution must have at least one used path","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/mcp_login_service.py","lineNumber":159,"sourceCode":"    \"\"\"Discovered config files that failed to parse or validate, `(path, error)`.\n\n    Surfaced even on success: a broken project `.mcp.json` (or an approved\n    server that fails per-server validation) can be dropped while another\n    discovered config still loads. Reporting it here matches\n    `resolve_and_load_mcp_tools`, which emits the same failures as\n    `status=\"error\"` rows rather than swallowing them. On `ConfigResolutionError`\n    the reason is already embedded in `message`, so the field lives only here.\n    See `format_load_errors_notice`.\"\"\"\n\n    def __post_init__(self) -> None:\n        \"\"\"Enforce the non-empty `used_paths` invariant.\n\n        Raises:\n            ValueError: If `used_paths` is empty.\n        \"\"\"\n        if not self.used_paths:\n            msg = \"ConfigResolution must have at least one used path\"\n            raise ValueError(msg)\n\n    @property\n    def search_label(self) -> str:\n        \"\"\"Human-readable join of the paths backing this resolution.\"\"\"\n        return \", \".join(str(path) for path in self.used_paths)\n\n\n@dataclass(frozen=True)\nclass ServerSelection:\n    \"\"\"Resolved server config plus enough context for error messages.\"\"\"\n\n    server_name: str\n    \"\"\"Selected MCP server name (matches an `mcpServers` key).\"\"\"\n\n    server_config: McpServerSpec\n    \"\"\"Validated server config payload for `mcp_auth.login`.\"\"\"\n\n    search_label: str = \"\"","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/mcp_login_service.py#L141-L177","documentation":"ConfigResolution's __post_init__ invariant requires at least one used path: an MCP config resolution must be backed by at least one config source. Constructing a ConfigResolution with an empty used_paths list fails this dataclass invariant with a ValueError.","triggerScenarios":"Programmatically constructing `ConfigResolution(...)` (e.g. in tests or custom tooling around resolve_mcp_config) passing `used_paths=[]`, or building one from a resolution pipeline that collected no paths.","commonSituations":"Test fixtures that build ConfigResolution objects manually and forget to include the fallback global config path; custom code that filters out all config sources before constructing the resolution.","solutions":["Pass at least one path in used_paths — typically the global user config path that always participates in resolution.","If no sources exist, create/point to a config file first rather than constructing an empty resolution.","In tests, use the real resolver output or seed a temp config file instead of hand-building ConfigResolution."],"exampleFix":"// before\nConfigResolution(value=servers, used_paths=[])\n// after\nConfigResolution(value=servers, used_paths=[Path(user_config_path)])","handlingStrategy":"validation","validationCode":"if not used_paths:\n    raise ValueError(\"ConfigResolution needs at least one source path (e.g. the global user config)\")","typeGuard":null,"tryCatchPattern":"try:\n    resolution = build_resolution(...)\nexcept ValueError as exc:\n    if \"at least one used path\" in str(exc):\n        resolution = default_resolution_with_global_config()\n    else:\n        raise","preventionTips":["Always include the global user config path in used_paths","Prefer running the real resolver over hand-building ConfigResolution in tests","Filter config sources before resolution, not after, so paths stay non-empty"],"tags":["mcp","config","invariant","value-error"],"backgroundTag":"invariant-violation","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}