{"record":{"id":"d8b00da964b5981d","repo":"oraios/serena","slug":"context-name-not-found-in-serenapaths-user-co","errorCode":null,"errorMessage":"Context {name} not found in {SerenaPaths().user_contexts_dir} or in {SERENAS_OWN_CONTEXT_YAMLS_DIR}.Available contexts:\n{cls.list_registered_context_names()}","messagePattern":"Context (.+?) not found in (.+?) or in (.+?)\\.Available contexts:\n(.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/serena/config/context_mode.py","lineNumber":226,"sourceCode":"    def get_path(cls, name: str, instance: Self | None = None) -> str:\n        \"\"\"Get the path to the YAML file for a context.\n\n        :param name: The name of the context\n        :param instance: Optional context instance. If provided and it has a stored path, that path is returned.\n        :return: The path to the context's YAML file\n        \"\"\"\n        # If we have an instance with a stored path, use that\n        if instance is not None and instance._yaml_path is not None:\n            return str(instance._yaml_path)\n\n        fname = f\"{name}.yml\"\n        custom_context_path = os.path.join(SerenaPaths().user_contexts_dir, fname)\n        if os.path.exists(custom_context_path):\n            return custom_context_path\n\n        own_yaml_path = os.path.join(SERENAS_OWN_CONTEXT_YAMLS_DIR, fname)\n        if not os.path.exists(own_yaml_path):\n            raise FileNotFoundError(\n                f\"Context {name} not found in {SerenaPaths().user_contexts_dir} or in {SERENAS_OWN_CONTEXT_YAMLS_DIR}.\"\n                f\"Available contexts:\\n{cls.list_registered_context_names()}\"\n            )\n        return own_yaml_path\n\n    @classmethod\n    def from_name(cls, name: str) -> Self:\n        \"\"\"Load a registered Serena context.\"\"\"\n        legacy_name_mapping = {\n            \"ide-assistant\": \"claude-code\",\n        }\n        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]","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/config/context_mode.py#L208-L244","documentation":"Analogous to modes: SerenaContext.get_path resolves a context name to a YAML in the user contexts dir, then Serena's bundled context YAMLs. If <name>.yml exists in neither, FileNotFoundError is raised listing all registered context names.","triggerScenarios":"Starting Serena with --context <name> or context config referencing a context that has no YAML in ~/.serena/contexts or Serena's own context resources — typo in context name, context removed/renamed in a newer version, or custom context file never created.","commonSituations":"Typos like --context deskop-app instead of desktop-app; following outdated tutorials referencing removed contexts (e.g. old 'ide-assistant' names); custom context YAMLs in a different HOME/config dir; containers where ~/.serena wasn't mounted.","solutions":["Use an exact context name from the error's 'Available contexts' list (cls.list_registered_context_names())","Create the custom context YAML at SerenaPaths().user_contexts_dir/<name>.yml","Fix the context name in CLI flags or serena_config","If upgrading, rename to the new context names per release notes"],"exampleFix":"// before\nserena --context codex\n// after\nserena --context codex-cli  # name from the available contexts list","handlingStrategy":"validation","validationCode":"from serena.config.context_mode import SerenaContext\nnames = SerenaContext.list_registered_context_names()\nassert context_name in names, f\"Unknown context {context_name}; available: {names}\"","typeGuard":null,"tryCatchPattern":"try:\n    ctx = SerenaContext.from_name(context_name)\nexcept FileNotFoundError as e:\n    logger.warning(\"%s; falling back to default context\", e)\n    ctx = SerenaContext.from_name(\"default\")","preventionTips":["List registered contexts before configuring","Store custom contexts in ~/.serena/contexts with matching filenames","After upgrades, verify context names still exist","Copy exact names from the error's available contexts list"],"tags":["configuration","file-not-found","contexts"],"backgroundTag":"config-file-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}