oraios/serena · error · ValueError

Project '{project_name}' not found in Serena configuration;

Error message

Project '{project_name}' not found in Serena configuration; valid project names: {self.project_names}

What it means

SerenaConfig.remove_project(name) searches the in-memory projects list for a project whose project_name equals the given name and deletes it, persisting the change. If no registered project has that name, it raises ValueError listing the currently valid project names via self.project_names.

Source

Thrown at src/serena/config/serena_config.py:1294

        new_project = Project(
            project_root=str(project_root),
            project_config=project_config,
            is_newly_created=True,
            serena_config=self,
        )
        self.add_registered_project(RegisteredProject.from_project_instance(new_project))

        return new_project

    def remove_project(self, project_name: str) -> None:
        # find the index of the project with the desired name and remove it
        for i, project in enumerate(list(self.projects)):
            if project.project_name == project_name:
                del self.projects[i]
                break
        else:
            raise ValueError(f"Project '{project_name}' not found in Serena configuration; valid project names: {self.project_names}")
        self._persist_projects()

    def _persist_projects(self) -> None:
        """
        Persists the list of registered projects, merging it with the list currently found on disk
        (parallel agent instances may have added or removed projects in the meantime).
        """
        if self.config_file_path is None:
            return
        persisted = SerenaConfig.from_config_file()
        combined_projects = []
        handled_project_paths = set()
        for p in persisted.projects + self.projects:
            str_path = str(p.project_root)
            if str_path not in handled_project_paths:
                combined_projects.append(p)
                handled_project_paths.add(str_path)
        persisted.projects = combined_projects

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Check the valid names in the error message (or config.project_names) and retry with an exact match.
  2. Make removal idempotent: if name not in config.project_names, skip the call.
  3. If a parallel agent removed it, reload the config and re-check before persisting.

Example fix

// before
config.remove_project('my-proj')  # ValueError: not found
// after
if 'my-proj' in config.project_names:
    config.remove_project('my-proj')
Defensive patterns

Strategy: validation

Validate before calling

if project_name not in config.project_names:
    print('available:', config.project_names)  # abort or pick a valid name

Type guard

def is_registered_name(config, name: str) -> bool:
    return name in config.project_names

Try / catch

try:
    config.remove_project(project_name)
except ValueError as e:
    if 'not found' in str(e):
        pass  # already removed; treat as idempotent no-op
    else:
        raise

Prevention

When it happens

Trigger: Calling remove_project('typo-name') or remove_project('removed-project') during config.apply(); also triggered when the project was already removed (e.g. by a parallel agent merging state) so the name no longer exists.

Common situations: Typo in the project name; project was unregistered in another Serena instance/agent process; script assumes registration that never happened; stale references after editing serena_config.yml by hand.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29). Data as JSON: /api/errors/820ccb2e23f02c5c. Report an issue: GitHub.