oraios/serena · error · FileNotFoundError
Internal context '{from_internal}' not found in {SERENAS_OWN
Error message
Internal context '{from_internal}' not found in {SERENAS_OWN_CONTEXT_YAMLS_DIR}. Available contexts: {SerenaAgentContext.list_registered_context_names()} What it means
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.
Source
Thrown at src/serena/cli.py:629
"--name",
"-n",
type=str,
default=None,
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",
)
@click.option("--from-internal", "from_internal", type=str, default=None, help="Copy from an internal context.")
def create(name: str, from_internal: str) -> None:
if not (name or from_internal):
raise click.UsageError("Provide at least one of --name or --from-internal.")
ctx_name = name or from_internal
dest = os.path.join(SerenaPaths().user_contexts_dir, f"{ctx_name}.yml")
src = (
os.path.join(SERENAS_OWN_CONTEXT_YAMLS_DIR, f"{from_internal}.yml")
if from_internal
else os.path.join(SERENAS_OWN_CONTEXT_YAMLS_DIR, "context.template.yml")
)
if not os.path.exists(src):
raise FileNotFoundError(
f"Internal context '{from_internal}' not found in {SERENAS_OWN_CONTEXT_YAMLS_DIR}. Available contexts: {SerenaAgentContext.list_registered_context_names()}"
)
os.makedirs(os.path.dirname(dest), exist_ok=True)
shutil.copyfile(src, dest)
click.echo(f"Created context '{ctx_name}' at {dest}")
_open_in_editor(dest)
@staticmethod
@click.command("edit", help="Edit a custom context YAML file.", context_settings={"max_content_width": _MAX_CONTENT_WIDTH})
@click.argument("context_name")
def edit(context_name: str) -> None:
path = os.path.join(SerenaPaths().user_contexts_dir, f"{context_name}.yml")
if not os.path.exists(path):
if context_name in SerenaAgentContext.list_registered_context_names(include_user_contexts=False):
click.echo(
f"Context '{context_name}' is an internal context and cannot be edited directly. "
f"Use 'context create --from-internal {context_name}' to create a custom context that overrides it before editing."
)View on GitHub (pinned to 7fcbca7e62)
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.
Example fix
// before serena context create my-ctx --from agent-test // after serena context create my-ctx --from agent # exact bundled name, or omit --from
Defensive patterns
Strategy: validation
Validate before calling
import os
from serena.constants import SERENAS_OWN_CONTEXT_YAMLS_DIR
def internal_context_exists(name: str) -> bool:
src = os.path.join(SERENAS_OWN_CONTEXT_YAMLS_DIR, f"{name}.yml")
return os.path.exists(src) Try / catch
try:
create_context(name, from_internal=base)
except FileNotFoundError:
log.error('Unknown base context %r; use one of %s or omit --from', base, SerenaAgentContext.list_registered_context_names()) Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Internal mode '{from_internal}' not found in {SERENAS_OWN_MO
- Context {name} not found in {SerenaPaths().user_contexts_dir
- Unknown language '{lang}'. Supported: {all_langs}
- Mode {name} not found in {SerenaPaths().user_modes_dir} or i
- Internal mode '{name}' not found in {INTERNAL_MODE_YAMLS_DIR
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/f64859cc06cd5ce7.
Report an issue: GitHub.