{"record":{"id":"553e2b8f475857ad","repo":"oraios/serena","slug":"context-file-not-found-path-resolve","errorCode":null,"errorMessage":"Context file not found: {path.resolve()}","messagePattern":"Context file not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/serena/config/context_mode.py","lineNumber":256,"sourceCode":"        if name in legacy_name_mapping:\n            log.warning(\n                f\"Context name '{name}' is deprecated and has been renamed to '{legacy_name_mapping[name]}'. \"\n                f\"Please update your configuration; refer to the configuration guide for more details: \"\n                \"https://oraios.github.io/serena/02-usage/050_configuration.html#contexts\"\n            )\n            name = legacy_name_mapping[name]\n        context_path = cls.get_path(name)\n        return cls.from_yaml(context_path)\n\n    @classmethod\n    def load(cls, name_or_path: str | Path) -> Self:\n        # If it is a path or looks like a path, load from file\n        if isinstance(name_or_path, Path) or looks_like_yaml_path(str(name_or_path)):\n            path = Path(name_or_path)\n            if path.exists() and path.is_file():\n                return cls.from_yaml(name_or_path)\n            else:\n                raise FileNotFoundError(f\"Context file not found: {path.resolve()}\")\n\n        return cls.from_name(str(name_or_path))\n\n    @classmethod\n    def list_registered_context_names(cls, include_user_contexts: bool = True) -> list[str]:\n        \"\"\"Names of all registered contexts (from the corresponding YAML files in the serena repo).\"\"\"\n        contexts = [f.stem for f in Path(SERENAS_OWN_CONTEXT_YAMLS_DIR).glob(\"*.yml\")]\n        if include_user_contexts:\n            contexts += cls.list_custom_context_names()\n        return sorted(set(contexts))\n\n    @classmethod\n    def list_custom_context_names(cls) -> list[str]:\n        \"\"\"Names of all custom contexts defined by the user.\"\"\"\n        return [f.stem for f in Path(SerenaPaths().user_contexts_dir).glob(\"*.yml\")]\n\n    @classmethod\n    def load_default(cls) -> Self:","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/config/context_mode.py#L238-L274","documentation":"Serena's Context.load() accepts either a registered context name or a path to a YAML context file. This FileNotFoundError is raised when the argument looks like a YAML path (or is a Path object) but no file exists at that location. It means the loader determined you meant a file, not a name, and the file is missing.","triggerScenarios":"Calling Context.load(Path('/path/to/context.yml')) or Context.load('./my_context.yaml') where the path does not exist or is a directory (path.is_file() fails). Note: if the path exists but is not a file, this error is also raised.","commonSituations":"Typos in the path, file deleted or moved after being referenced in a config, running from a different working directory with a relative path, passing a directory instead of a YAML file, or referencing a user context file that was never created.","solutions":["Verify the path exists and is a file: run ls/path.exists() and path.is_file() on the exact path.","If you meant a registered context, pass just the name (e.g. 'desktop-app') without a .yml extension or path separators.","If using a relative path, make it absolute or run the command from the intended working directory.","Use Context.list_registered_context_names() to see available contexts, or copy a shipped YAML from the serena repo as a starting point."],"exampleFix":"// before\nctx = Context.load(\"./cotexts/my_context.yml\")  # typo, file not found\n// after\nctx = Context.load(\"./contexts/my_context.yml\")  # corrected path, or use a registered name:\n# ctx = Context.load(\"my_context\")","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef validate_context_path(name_or_path):\n    p = Path(name_or_path)\n    if p.suffix in (\".yml\", \".yaml\") or isinstance(name_or_path, Path):\n        if not (p.exists() and p.is_file()):\n            raise FileNotFoundError(f\"Context file not found: {p.resolve()}\")\n    return p","typeGuard":"def is_existing_yaml_file(name_or_path) -> bool:\n    p = Path(name_or_path)\n    return p.exists() and p.is_file()","tryCatchPattern":"from serena.config.context import Context\n\ntry:\n    ctx = Context.load(name_or_path)\nexcept FileNotFoundError as e:\n    print(f\"{e}; available: {Context.list_registered_context_names()}\")\n    ctx = Context.load(\"default\")","preventionTips":["Use registered context names instead of file paths whenever possible.","Use absolute paths for custom context YAML files.","Call list_registered_context_names() to discover valid names before loading.","Add existence checks (Path.is_file()) before passing a path to Context.load()."],"tags":["python","file-not-found","configuration"],"backgroundTag":"file-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}