Skip to content

serena init/config load crashes when generated config has empty projects key #1407

@ShivamB25

Description

@ShivamB25

I have:

  • read the relevant parts of the documentation and verified that the issue cannot be solved by adjusting configuration
  • understood that the Serena Dashboard can be disabled through the config
  • understood that, by default, a client session will start a separate instance of a Serena server.
  • understood that, for multi-agent setups, the Streamable HTTP/SSE mode should be used.
  • understood that non-project files are ignored using either .gitignore or the corresponding setting in .serena/project.yml
  • looked for similar issues and discussions, including closed ones
  • made sure it's an actual issue, not a question (use GitHub Discussions instead).

If you have encountered an actual issue:

  • If using language servers (not the JetBrains plugin),
    • I performed <uv invocation> serena project health-check (not applicable: this fails during init/config loading before project setup)
    • I indexed the project as described in the documentation (not applicable: this fails during init/config loading before project setup)
  • I added sufficient explanation of my setup: the MCP client, the OS, the programming language(s), any config adjustments or relevant project specifics
  • I explained how the issue arose and, where possible, added instructions on how to reproduce it
  • If the issue happens on an open-source project, I have added the link (not project-specific)
  • I provided a meaningful title and description

Summary

SerenaConfig.from_config_file() crashes when serena_config.yml contains an empty projects: key. The generated config in my environment ended with projects: (no list entries), which YAML loads as None; the config loader then tries to iterate it.

Steps to reproduce

Install and initialize Serena:

uv tool install -p 3.13 serena-agent@latest --prerelease=allow
serena init

In the generated/current config, the final section is:

# the list of registered project paths (updated automatically).
projects:

Then loading the config reproduces the crash:

/home/ubuntu/.local/share/uv/tools/serena-agent/bin/python - <<'PY'
from serena.config.serena_config import SerenaConfig
SerenaConfig.from_config_file()
PY

Actual result

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/home/ubuntu/.local/share/uv/tools/serena-agent/lib/python3.13/site-packages/serena/config/serena_config.py", line 846, in from_config_file
    for path in loaded_commented_yaml["projects"]:
                ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable

The same traceback was seen from serena init:

Serena version: 1.1.2
...
File ".../serena/cli.py", line 158, in init
  serena_config = SerenaConfig.from_config_file()
...
TypeError: 'NoneType' object is not iterable

Expected result

Either:

  1. the generated template should use projects: [], or
  2. from_config_file() should treat a null/empty projects: value as an empty list and continue.

A config generated by Serena should not cause config loading or serena init to crash.

Environment

  • Serena package: serena-agent 1.1.2
  • Install command: uv tool install -p 3.13 serena-agent@latest --prerelease=allow
  • Serena tool Python: 3.13
  • Host Python: Python 3.12.3
  • OS: Ubuntu Linux on aarch64 (Linux 6.17.0-1010-oracle)
  • MCP/client context: setting up Serena MCP for a CLI agent environment; no project-specific language server involved yet

Likely cause

serena/config/serena_config.py checks only that the projects key exists, then iterates it:

if "projects" not in loaded_commented_yaml:
    raise SerenaConfigError(...)
instance.projects = []
for path in loaded_commented_yaml["projects"]:
    ...

When YAML contains projects: with no value, loaded_commented_yaml["projects"] is None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions