oraios/serena · error

Invalid YAML in {path}: values that start with `*` must be q

Error message

Invalid YAML in {path}: values that start with `*` must be quoted. This often happens in `ignored_paths` when using gitignore-style globs like `"**/bin/**"` or `"**/obj/**"`.

What it means

load_yaml parses a YAML file with ruamel and raises ValueError when the parser fails with an 'undefined alias' error. YAML treats a leading `*` as an alias reference, so unquoted gitignore-style glob values like **/bin/** are parsed as (undefined) YAML aliases rather than strings. Serena raises this specific message because this most commonly happens in `ignored_paths` settings.

Source

Thrown at src/serena/util/yaml.py:78

# item comment indices: (post key, pre key, post value, pre value)
ITEM_COMMENT_INDEX_BEFORE = 1  # (pre-key; must be a list of CommentToken at this index)
ITEM_COMMENT_INDEX_AFTER = 2  # (post-value; must be an instance of CommentToken at this index)


def load_yaml(path: str, comment_normalisation: YamlCommentNormalisation = YamlCommentNormalisation.NONE) -> CommentedMap:
    """
    :param path: the path to the YAML file to load
    :param comment_normalisation: the comment normalisation to apply after loading
    :return: the loaded commented map
    """
    with open(path, encoding=SERENA_FILE_ENCODING) as f:
        yaml = _create_yaml(preserve_comments=True)
        try:
            commented_map: CommentedMap | None = yaml.load(f)
        except Exception as e:
            msg = str(e)
            if "undefined alias" in msg:
                raise ValueError(
                    f"Invalid YAML in {path}: values that start with `*` must be quoted. "
                    "This often happens in `ignored_paths` when using gitignore-style globs like "
                    '`"**/bin/**"` or `"**/obj/**"`.'
                ) from e
            raise
    if commented_map is None:  # ruamel returns None for empty documents, but we want an empty CommentedMap
        commented_map = CommentedMap()
    normalise_yaml_comments(commented_map, comment_normalisation)
    return commented_map


def normalise_yaml_comments(commented_map: CommentedMap, comment_normalisation: YamlCommentNormalisation) -> None:
    """
    Applies the given comment normalisation to the given commented map in-place.

    :param commented_map: the commented map whose comments are to be normalised
    :param comment_normalisation: the comment normalisation to apply
    """

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Open the file named in the error and quote every value that starts with `*`, e.g. `"**/bin/**"`.
  2. Re-run the command that loaded the config; the ValueError reports the exact path.
  3. If the alias is intentional, define the corresponding YAML anchor (`&name`) before the alias.

Example fix

// before
ignored_paths:
  - **/bin/**
  - **/obj/**
// after
ignored_paths:
  - "**/bin/**"
  - "**/obj/**"
Defensive patterns

Strategy: validation

Validate before calling

import re
from pathlib import Path

def validate_yaml_globs(config_path: str) -> list[str]:
    issues = []
    for i, line in enumerate(Path(config_path).read_text().splitlines(), 1):
        stripped = line.split('#', 1)[0].rstrip()
        if re.search(r':\s+\*', stripped) or re.search(r"-\s+\*", stripped):
            issues.append(f"line {i}: unquoted value starting with '*': {stripped.strip()}")
    return issues

Type guard

def is_safe_yaml_scalar(value: str) -> bool:
    return not value.lstrip().startswith('*')

Try / catch

try:
    cfg = load_yaml(path)
except ValueError as e:
    if 'must be quoted' in str(e):
        fix_unquoted_globs(path)  # quote all values starting with '*'
        cfg = load_yaml(path)
    else:
        raise

Prevention

When it happens

Trigger: Calling load_yaml (directly or via from_config_file/_load_yaml_dict) on a config file where a scalar value starts with `*` and is not quoted, e.g. `ignored_paths: [**/bin/**]`.

Common situations: Users hand-editing serena config files and copying gitignore glob patterns into ignored_paths without quoting; tools generating YAML that omit quotes around values starting with `*`.

Related errors


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