langflow-ai/langflow · error · SystemExit
error: invalid JSON in {source}: {exc}
Error message
error: invalid JSON in {source}: {exc} What it means
Printed and raised (exit code 2) by _parse in check_migration_append_only.py when json.loads fails on the migration-table JSON — either the current working-tree file or the baseline blob fetched via `git show`. The message includes the source label and the JSONDecodeError so you can tell which side is malformed.
Source
Thrown at scripts/migrate/check_migration_append_only.py:93
raise SystemExit(msg) from None
if completed.returncode != 0:
# Most likely: file not present at base ref. We treat that as
# "no baseline" and return None.
return None
return completed.stdout
def _parse(raw: str, *, source: str) -> tuple[list[dict], list[dict]]:
"""Return ``(entries, ambiguous_bare_names)`` from a migration-table JSON.
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] = {}View on GitHub (pinned to 976ec789d2)
Solutions
- Identify which source is bad from the message's {source} label, then run it through a JSON validator or `python -m json.tool <file>`
- Fix syntax issues: trailing commas, unquoted keys, smart quotes, unclosed brackets
- If the baseline (git ref) is corrupt, compare against an earlier known-good ref or fix the file and amend the commit
- Re-run the script to confirm it parses both sides before trusting the append-only comparison
Example fix
# before
python -m json.tool migrations.json # reveals: Expecting ',' delimiter
# fix the reported line, e.g. remove trailing comma:
{"entries": [{"name": "0001"},]},
# after
{"entries": [{"name": "0001"}]} Defensive patterns
Strategy: validation
Validate before calling
import json
json.loads(open("path/to/migration_table.json").read()) # raises before the script if malformed
# CI gate: python -m json.tool migrations/*.json Try / catch
# shell: validate before running the checker python -m json.tool migrations/migration_table.json > /dev/null \ && python scripts/migrate/check_migration_append_only.py
Prevention
- Run python -m json.tool (or an editor JSON linter) on migration tables before committing
- Never hand-edit migration JSON without a schema/JSON validator in pre-commit
- Reject smart quotes and trailing commas at review time for JSON files
When it happens
Trigger: Hand-editing the migration-table JSON and leaving a trailing comma / stray character; or the baseline version at the compared git ref being corrupt (e.g. a merge artifact), causing `git show` to return invalid JSON.
Common situations: Manual edits to migration tables without running a JSON validator; CRLF or BOM introduced by Windows editors; conflict resolution that leaves duplicate keys or fragments in the file.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- error: {source} top-level value must be an object
- git is not available; cannot check append-only invariant.
- Invalid flow data
- Invalid JSON format.
- No valid MCP server found in the input.
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/de049307204965be.
Report an issue: GitHub.