oraios/serena · error · ValueError

Bare "{self.GLOBAL_TOPIC}" is not a valid memory name. Use "

Error message

Bare "{self.GLOBAL_TOPIC}" is not a valid memory name. Use "{self.GLOBAL_TOPIC}/<name>" to address a global memory.

What it means

The reserved topic 'global' addresses global (cross-project) memories, but the bare name 'global' alone is not a memory. get_memory_file_path raises ValueError telling you to use the form 'global/<name>'. Global memories resolve against the global memories directory with the prefix stripped.

Source

Thrown at src/serena/memories/memory_manager.py:188

        subdir.mkdir(parents=True, exist_ok=True)
        return candidate

    def get_memory_file_path(self, name: str) -> Path:
        name = self._sanitize_name(name)
        parts = name.split("/")

        if ".." in parts:
            raise ValueError(f"Memory name cannot contain '..' segments. Got: {name}")

        # Reject absolute names and empty path segments: pathlib discards the base directory when
        # joined with an absolute path (e.g. "/etc/cron.d/backdoor" would reset to "/etc/cron.d"),
        # letting a memory name escape the sandbox. A leading "/" produces an empty first segment.
        if os.path.isabs(name) or "" in parts:
            raise ValueError(f"Memory name cannot be absolute or contain empty path segments. Got: {name}")

        if self._is_global(name):
            if name == self.GLOBAL_TOPIC:
                raise ValueError(
                    f'Bare "{self.GLOBAL_TOPIC}" is not a valid memory name. Use "{self.GLOBAL_TOPIC}/<name>" to address a global memory.'
                )
            # Strip "global/" prefix and resolve against global dir
            sub_name = name[len(self.GLOBAL_TOPIC) + 1 :]
            return self._resolve_memory_path(self._global_memory_dir, sub_name.split("/"))

        # Project-local memory
        assert self._project_memory_dir is not None, "Project dir was not passed at initialization"
        return self._resolve_memory_path(self._project_memory_dir, parts)

    def _check_write_access(self, name: str, is_tool_context: bool) -> None:
        # in tool context, memories can be read-only
        if is_tool_context and self._is_read_only_memory(name):
            raise PermissionError(f"Attempted to write to read_only memory: '{name}')")

    def load_memory(self, name: str) -> str:
        name = self._sanitize_name(name)
        self._check_not_ignored(name)

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Append the actual memory name: use "global/<name>" instead of "global".
  2. To see available global memories, enumerate files in the global memories directory (list_memories output shows global/<name> entries).
  3. If you want a project memory, drop the 'global' prefix entirely and use a plain name.
  4. Wrap the call defensively and treat the error message's suggested format as the corrected name.

Example fix

// before
content = manager.load_memory("global")
// after
content = manager.load_memory("global/coding_conventions")
Defensive patterns

Strategy: validation

Validate before calling

if name == "global":
    raise ValueError('use "global/<memory-name>", not the bare topic "global"')

Type guard

def is_valid_memory_name(name: str) -> bool:
    return name != "global" and bool(name)

Try / catch

try:
    content = manager.load_memory(name)
except ValueError as e:
    if "not a valid memory name" in str(e):
        names = manager.list_memories()
        content = next(manager.load_memory(n) for n in names if n.startswith("global/"))
    else:
        raise

Prevention

When it happens

Trigger: Calling load_memory/save_memory/etc. with exactly "global" (after _sanitize_name strips 'mem:' and '.md'), instead of "global/<memory-name>".

Common situations: Agents listing memories and mistaking the 'global' topic directory for a memory item; users trying to read all global memories at once by the topic name; scripts that join a topic prefix without appending a memory name.

Related errors


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