{"record":{"id":"ba538c12dc1f2b4c","repo":"langflow-ai/langflow","slug":"orjson-is-required-for-update-index-same-dep-sc","errorCode":null,"errorMessage":"orjson is required for --update-index (same dep scripts/build_component_index.py uses).  Run this script under ``uv run``.","messagePattern":"orjson is required for --update-index \\(same dep scripts/build_component_index\\.py uses\\)\\.  Run this script under ``uv run``\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"scripts/migrate/port_bundle.py","lineNumber":1502,"sourceCode":"        dst.write_text(_render_pilot_test(plan), encoding=\"utf-8\")\n    return actions\n\n\ndef _update_component_index(plan: PortPlan, *, apply: bool) -> list[str]:\n    if not COMPONENT_INDEX_PATH.is_file():\n        return []\n    actions = [f\"surgically remove {plan.bundle!r} category from {COMPONENT_INDEX_PATH.relative_to(REPO_ROOT)}\"]\n    if not apply:\n        return actions\n    try:\n        import orjson\n    except ImportError as exc:\n        msg = (\n            \"orjson is required for --update-index (same dep \"\n            \"scripts/build_component_index.py uses).  Run this script \"\n            \"under ``uv run``.\"\n        )\n        raise SystemExit(msg) from exc\n    import hashlib\n\n    with COMPONENT_INDEX_PATH.open(\"rb\") as f:\n        idx = json.loads(f.read())\n    entry = next((e for e in idx[\"entries\"] if e[0] == plan.bundle), None)\n    if entry is None:\n        actions.append(f\"  (no {plan.bundle!r} entry in index; nothing to do)\")\n        return actions\n    n_components = len(entry[1])\n    idx[\"entries\"] = [e for e in idx[\"entries\"] if e[0] != plan.bundle]\n    idx[\"metadata\"][\"num_modules\"] -= 1\n    idx[\"metadata\"][\"num_components\"] -= n_components\n\n    idx.pop(\"sha256\", None)\n    payload = orjson.dumps(idx, option=orjson.OPT_SORT_KEYS)\n    idx[\"sha256\"] = hashlib.sha256(payload).hexdigest()\n    out = orjson.dumps(idx, option=orjson.OPT_SORT_KEYS | orjson.OPT_INDENT_2)\n    COMPONENT_INDEX_PATH.write_bytes(out + b\"\\n\")","sourceCodeStart":1484,"sourceCodeEnd":1520,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/scripts/migrate/port_bundle.py#L1484-L1520","documentation":"port_bundle.py needs orjson (the same dependency scripts/build_component_index.py uses) when removing a bundle's category from the component index with --update-index. The script aborts with SystemExit when orjson cannot be imported, because index surgery is skipped rather than done with a different parser. The fix is to run under 'uv run' so the project environment with orjson is used.","triggerScenarios":"Executing python scripts/migrate/port_bundle.py --apply --update-index with a bare system python or a venv that lacks orjson.","commonSituations":"Developer runs the script with 'python' instead of 'uv run'; CI image missing dev dependencies; a fresh virtualenv synced without the dev group.","solutions":["Run the script as 'uv run python scripts/migrate/port_bundle.py ... --update-index' so it executes in the workspace environment that has orjson.","Alternatively install orjson into the active environment: 'uv pip install orjson' (or add it to the dev group).","If index updates are not needed, drop --update-index and update the component index separately with scripts/build_component_index.py under uv."],"exampleFix":"# before\npython scripts/migrate/port_bundle.py --apply --update-index\n# after\nuv run python scripts/migrate/port_bundle.py --apply --update-index","handlingStrategy":"validation","validationCode":"import subprocess, sys\ntry:\n    import orjson  # noqa: F401\nexcept ImportError:\n    sys.exit(\"orjson missing — rerun as: uv run python scripts/migrate/port_bundle.py ...\")\nprint(\"orjson ok; safe to pass --update-index\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run repo scripts via 'uv run' so the workspace env (with orjson) is used.","Keep orjson in the dev dependency group of the scripts' environment.","Automate index updates with scripts/build_component_index.py under uv instead of ad-hoc interpreters."],"tags":["migration","dependencies","cli","uv"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}