{"record":{"id":"f64859cc06cd5ce7","repo":"oraios/serena","slug":"internal-context-from-internal-not-found-in-s","errorCode":null,"errorMessage":"Internal context '{from_internal}' not found in {SERENAS_OWN_CONTEXT_YAMLS_DIR}. Available contexts: {SerenaAgentContext.list_registered_context_names()}","messagePattern":"Internal context '(.+?)' not found in (.+?)\\. Available contexts: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/serena/cli.py","lineNumber":629,"sourceCode":"        \"--name\",\n        \"-n\",\n        type=str,\n        default=None,\n        help=\"Name for the new context. If --from-internal is passed may be left empty to create a context of the same name, which will then override the internal context\",\n    )\n    @click.option(\"--from-internal\", \"from_internal\", type=str, default=None, help=\"Copy from an internal context.\")\n    def create(name: str, from_internal: str) -> None:\n        if not (name or from_internal):\n            raise click.UsageError(\"Provide at least one of --name or --from-internal.\")\n        ctx_name = name or from_internal\n        dest = os.path.join(SerenaPaths().user_contexts_dir, f\"{ctx_name}.yml\")\n        src = (\n            os.path.join(SERENAS_OWN_CONTEXT_YAMLS_DIR, f\"{from_internal}.yml\")\n            if from_internal\n            else os.path.join(SERENAS_OWN_CONTEXT_YAMLS_DIR, \"context.template.yml\")\n        )\n        if not os.path.exists(src):\n            raise FileNotFoundError(\n                f\"Internal context '{from_internal}' not found in {SERENAS_OWN_CONTEXT_YAMLS_DIR}. Available contexts: {SerenaAgentContext.list_registered_context_names()}\"\n            )\n        os.makedirs(os.path.dirname(dest), exist_ok=True)\n        shutil.copyfile(src, dest)\n        click.echo(f\"Created context '{ctx_name}' at {dest}\")\n        _open_in_editor(dest)\n\n    @staticmethod\n    @click.command(\"edit\", help=\"Edit a custom context YAML file.\", context_settings={\"max_content_width\": _MAX_CONTENT_WIDTH})\n    @click.argument(\"context_name\")\n    def edit(context_name: str) -> None:\n        path = os.path.join(SerenaPaths().user_contexts_dir, f\"{context_name}.yml\")\n        if not os.path.exists(path):\n            if context_name in SerenaAgentContext.list_registered_context_names(include_user_contexts=False):\n                click.echo(\n                    f\"Context '{context_name}' is an internal context and cannot be edited directly. \"\n                    f\"Use 'context create --from-internal {context_name}' to create a custom context that overrides it before editing.\"\n                )","sourceCodeStart":611,"sourceCodeEnd":647,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/cli.py#L611-L647","documentation":"The context analogue of error 17: `serena context create --from <internal-context>` copies a bundled context YAML from SERENAS_OWN_CONTEXT_YAMLS_DIR, and raises FileNotFoundError when the requested internal context yml is missing, listing all registered context names. It guards against creating a custom context from a nonexistent base.","triggerScenarios":"Running `serena context create <name> --from <internal>` where `<internal>.yml` does not exist in Serena's own resources/config/contexts directory (typo, renamed/removed context in a newer version), or the bundled context.template.yml itself is missing due to a broken install.","commonSituations":"Typos in built-in context names (e.g. 'desktop-app' vs actual name); following docs for an older Serena version whose contexts were renamed; partially installed package missing resource YAMLs.","solutions":["Use an exact name from the 'Available contexts' list in the error message (or list files in resources/config/contexts).","Omit --from to base the new context on context.template.yml.","Reinstall/upgrade Serena if bundled resource files are missing from the installation."],"exampleFix":"// before\nserena context create my-ctx --from agent-test\n// after\nserena context create my-ctx --from agent   # exact bundled name, or omit --from","handlingStrategy":"validation","validationCode":"import os\nfrom serena.constants import SERENAS_OWN_CONTEXT_YAMLS_DIR\ndef internal_context_exists(name: str) -> bool:\n    src = os.path.join(SERENAS_OWN_CONTEXT_YAMLS_DIR, f\"{name}.yml\")\n    return os.path.exists(src)","typeGuard":null,"tryCatchPattern":"try:\n    create_context(name, from_internal=base)\nexcept FileNotFoundError:\n    log.error('Unknown base context %r; use one of %s or omit --from', base, SerenaAgentContext.list_registered_context_names())","preventionTips":["Use exact built-in context names from the 'Available contexts' list or resources/config/contexts.","Omit --from to start from context.template.yml.","Re-verify context names after upgrading Serena since bundled contexts can be renamed or removed."],"tags":["cli","contexts","file-not-found","configuration"],"backgroundTag":"resource-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}