langflow-ai/langflow · error · SystemExit

error: {source} ambiguous_bare_names field must be a list

Error message

error: {source} ambiguous_bare_names field must be a list

What it means

Same CI guard script (check_migration_append_only.py): after validating that 'entries' is a list, it validates the companion 'ambiguous_bare_names' field, which records bare component names that map to more than one candidate. This field must also be a JSON list; the append-only invariant says a marker may never be removed and its 'candidates' may only grow, which only makes sense for list data. If the field exists but is not a list, the script prints 'error: {source} ambiguous_bare_names field must be a list' and exits 2.

Source

Thrown at scripts/migrate/check_migration_append_only.py:104

    Both lists default to empty when the field is absent so this script can
    compare across baselines that pre-date a given field.
    """
    try:
        data = json.loads(raw)
    except json.JSONDecodeError as exc:
        print(f"error: invalid JSON in {source}: {exc}", file=sys.stderr)
        raise SystemExit(2) from exc
    if not isinstance(data, dict):
        print(f"error: {source} top-level value must be an object", file=sys.stderr)
        raise SystemExit(2)
    entries = data.get("entries", [])
    if not isinstance(entries, list):
        print(f"error: {source} entries field must be a list", file=sys.stderr)
        raise SystemExit(2)
    ambig = data.get("ambiguous_bare_names", [])
    if not isinstance(ambig, list):
        print(f"error: {source} ambiguous_bare_names field must be a list", file=sys.stderr)
        raise SystemExit(2)
    return entries, ambig


def _compare(baseline: list[dict], current: list[dict]) -> list[str]:
    """Return human-readable violations; empty list means clean."""
    violations: list[str] = []
    current_by_key: dict[tuple[str, str], dict] = {}
    for entry in current:
        try:
            key = _entry_key(entry)
        except ValueError as exc:
            violations.append(str(exc))
            continue
        if key in current_by_key:
            violations.append(f"duplicate entry in current table: {key[0]}={key[1]!r}")
            continue
        current_by_key[key] = entry

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Change 'ambiguous_bare_names' back to an array of marker objects (each with the bare name and its 'candidates' list).
  2. Check both sides named in the error ({source} tells you whether it is the baseline or the current file) — fix whichever is malformed.
  3. Re-run `python scripts/migrate/check_migration_append_only.py` and confirm exit code 0 or 1 (1 means real append-only violations, not a schema problem).

Example fix

// before
"ambiguous_bare_names": { "Agent": ["ext:langchain:Agent", "ext:crewai:Agent"] }

// after
"ambiguous_bare_names": [
  { "bare_class_name": "Agent", "candidates": ["ext:langchain:Agent", "ext:crewai:Agent"] }
]
Defensive patterns

Strategy: validation

Validate before calling

import json

def ambig_field_ok(path: str) -> bool:
    data = json.loads(open(path, encoding="utf-8").read())
    return isinstance(data.get("ambiguous_bare_names", []), list)

Type guard

def has_list_ambiguous_names(data: dict) -> bool:
    ambig = data.get("ambiguous_bare_names", [])
    return isinstance(ambig, list) and all(isinstance(m, dict) and isinstance(m.get("candidates", []), list) for m in ambig)

Prevention

When it happens

Trigger: Running the check against a migration_table.json (current tree via --current default, or a --baseline file, or the git-show baseline) whose top-level 'ambiguous_bare_names' value is an object/string/number/bool. As with 'entries', a missing key defaults to [] and passes.

Common situations: Editing the table and converting the ambiguous-name markers into a dict keyed by class name (e.g. {"Agent": {...}}) for readability; copy-pasting a config-style object from a doc; schema drift after a tool rewrote the JSON.

Related errors


AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14). Data as JSON: /api/errors/51cc0b13f1cab029. Report an issue: GitHub.