{"record":{"id":"820ccb2e23f02c5c","repo":"oraios/serena","slug":"project-project-name-not-found-in-serena-confi","errorCode":null,"errorMessage":"Project '{project_name}' not found in Serena configuration; valid project names: {self.project_names}","messagePattern":"Project '(.+?)' not found in Serena configuration; valid project names: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/serena/config/serena_config.py","lineNumber":1294,"sourceCode":"\n        new_project = Project(\n            project_root=str(project_root),\n            project_config=project_config,\n            is_newly_created=True,\n            serena_config=self,\n        )\n        self.add_registered_project(RegisteredProject.from_project_instance(new_project))\n\n        return new_project\n\n    def remove_project(self, project_name: str) -> None:\n        # find the index of the project with the desired name and remove it\n        for i, project in enumerate(list(self.projects)):\n            if project.project_name == project_name:\n                del self.projects[i]\n                break\n        else:\n            raise ValueError(f\"Project '{project_name}' not found in Serena configuration; valid project names: {self.project_names}\")\n        self._persist_projects()\n\n    def _persist_projects(self) -> None:\n        \"\"\"\n        Persists the list of registered projects, merging it with the list currently found on disk\n        (parallel agent instances may have added or removed projects in the meantime).\n        \"\"\"\n        if self.config_file_path is None:\n            return\n        persisted = SerenaConfig.from_config_file()\n        combined_projects = []\n        handled_project_paths = set()\n        for p in persisted.projects + self.projects:\n            str_path = str(p.project_root)\n            if str_path not in handled_project_paths:\n                combined_projects.append(p)\n                handled_project_paths.add(str_path)\n        persisted.projects = combined_projects","sourceCodeStart":1276,"sourceCodeEnd":1312,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/config/serena_config.py#L1276-L1312","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the valid names in the error message (or config.project_names) and retry with an exact match.","Make removal idempotent: if name not in config.project_names, skip the call.","If a parallel agent removed it, reload the config and re-check before persisting."],"exampleFix":"// before\nconfig.remove_project('my-proj')  # ValueError: not found\n// after\nif 'my-proj' in config.project_names:\n    config.remove_project('my-proj')","handlingStrategy":"validation","validationCode":"if project_name not in config.project_names:\n    print('available:', config.project_names)  # abort or pick a valid name","typeGuard":"def is_registered_name(config, name: str) -> bool:\n    return name in config.project_names","tryCatchPattern":"try:\n    config.remove_project(project_name)\nexcept ValueError as e:\n    if 'not found' in str(e):\n        pass  # already removed; treat as idempotent no-op\n    else:\n        raise","preventionTips":["Read config.project_names before removing to confirm exact spelling","Make remove calls idempotent in scripts that may run multiple times","Reload the config after other agents/instances may have mutated project lists"],"tags":["configuration","not-found","python"],"backgroundTag":"entity-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}