{"record":{"id":"de049307204965be","repo":"langflow-ai/langflow","slug":"error-invalid-json-in-source-exc","errorCode":null,"errorMessage":"error: invalid JSON in {source}: {exc}","messagePattern":"error: invalid JSON in (.+?): (.+?)","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"scripts/migrate/check_migration_append_only.py","lineNumber":93,"sourceCode":"        raise SystemExit(msg) from None\n    if completed.returncode != 0:\n        # Most likely: file not present at base ref.  We treat that as\n        # \"no baseline\" and return None.\n        return None\n    return completed.stdout\n\n\ndef _parse(raw: str, *, source: str) -> tuple[list[dict], list[dict]]:\n    \"\"\"Return ``(entries, ambiguous_bare_names)`` from a migration-table JSON.\n\n    Both lists default to empty when the field is absent so this script can\n    compare across baselines that pre-date a given field.\n    \"\"\"\n    try:\n        data = json.loads(raw)\n    except json.JSONDecodeError as exc:\n        print(f\"error: invalid JSON in {source}: {exc}\", file=sys.stderr)\n        raise SystemExit(2) from exc\n    if not isinstance(data, dict):\n        print(f\"error: {source} top-level value must be an object\", file=sys.stderr)\n        raise SystemExit(2)\n    entries = data.get(\"entries\", [])\n    if not isinstance(entries, list):\n        print(f\"error: {source} entries field must be a list\", file=sys.stderr)\n        raise SystemExit(2)\n    ambig = data.get(\"ambiguous_bare_names\", [])\n    if not isinstance(ambig, list):\n        print(f\"error: {source} ambiguous_bare_names field must be a list\", file=sys.stderr)\n        raise SystemExit(2)\n    return entries, ambig\n\n\ndef _compare(baseline: list[dict], current: list[dict]) -> list[str]:\n    \"\"\"Return human-readable violations; empty list means clean.\"\"\"\n    violations: list[str] = []\n    current_by_key: dict[tuple[str, str], dict] = {}","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/scripts/migrate/check_migration_append_only.py#L75-L111","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\npython -m json.tool migrations.json  # reveals: Expecting ',' delimiter\n# fix the reported line, e.g. remove trailing comma:\n{\"entries\": [{\"name\": \"0001\"},]},\n\n# after\n{\"entries\": [{\"name\": \"0001\"}]}","handlingStrategy":"validation","validationCode":"import json\njson.loads(open(\"path/to/migration_table.json\").read())  # raises before the script if malformed\n# CI gate: python -m json.tool migrations/*.json","typeGuard":null,"tryCatchPattern":"# shell: validate before running the checker\npython -m json.tool migrations/migration_table.json > /dev/null \\\n  && python scripts/migrate/check_migration_append_only.py","preventionTips":["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"],"tags":["python","json","migrations","tooling","validation"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}