{"record":{"id":"728ce54f64142769","repo":"langflow-ai/langflow","slug":"lfx-bundle-already-referenced-in-root-pyproject","errorCode":null,"errorMessage":"lfx-{bundle} already referenced in {ROOT_PYPROJECT.relative_to(REPO_ROOT)}; not patching.","messagePattern":"lfx-(.+?) already referenced in (.+?); not patching\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"warning","filePath":"scripts/migrate/port_bundle.py","lineNumber":1147,"sourceCode":"            f\"Could not locate the {what} end marker ({needle!r}) in \"\n            \"pyproject.toml.  Re-add the ``langflow-extensions:bundle-*`` \"\n            \"marker pair before re-running -- see src/bundles/PORTING.md.\"\n        )\n        raise SystemExit(msg)\n    line_start = text.rfind(\"\\n\", 0, idx) + 1\n    return text[:line_start] + payload + text[line_start:]\n\n\ndef _patch_root_pyproject(plan: PortPlan, *, apply: bool) -> list[str]:\n    actions = [f\"patch {ROOT_PYPROJECT.relative_to(REPO_ROOT)}\"]\n    if not apply:\n        return actions\n    text = ROOT_PYPROJECT.read_text(encoding=\"utf-8\")\n    bundle = plan.bundle\n\n    if f\"lfx-{bundle}\" in text:\n        msg = f\"lfx-{bundle} already referenced in {ROOT_PYPROJECT.relative_to(REPO_ROOT)}; not patching.\"\n        raise SystemExit(msg)\n\n    dep_line = f'    \"lfx-{bundle}>=0.1.0\",\\n'\n    source_line = f\"lfx-{bundle} = {{ workspace = true }}\\n\"\n    member_line = f'    \"src/bundles/{bundle}\",\\n'\n\n    new_text = _insert_before_marker(text, \"# langflow-extensions:bundle-deps-end\", dep_line, what=\"bundle-deps\")\n    new_text = _insert_before_marker(\n        new_text, \"# langflow-extensions:bundle-sources-end\", source_line, what=\"bundle-sources\"\n    )\n    new_text = _insert_before_marker(\n        new_text, \"# langflow-extensions:bundle-members-end\", member_line, what=\"bundle-members\"\n    )\n    ROOT_PYPROJECT.write_text(new_text, encoding=\"utf-8\")\n    return actions\n\n\ndef _rewrite_consumers(plan: PortPlan, *, apply: bool) -> list[str]:\n    if not plan.consumer_rewrites:","sourceCodeStart":1129,"sourceCodeEnd":1165,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/scripts/migrate/port_bundle.py#L1129-L1165","documentation":"The bundle-migration helper scripts/migrate/port_bundle.py refuses to patch the root pyproject.toml when the string 'lfx-{bundle}' is already present anywhere in that file. This is a guard against double-applying dependency/source/workspace-member entries. It exits via SystemExit, aborting the port before any partial writes.","triggerScenarios":"Running port_bundle.py --apply (or any path that sets apply=True) twice for the same bundle; or porting a bundle whose name already appears in the root pyproject.toml from a previous migration or manual edit.","commonSituations":"Re-running a partially completed migration; a teammate already ported the bundle; a manual pyproject.toml edit referenced the bundle earlier and the marker-based insertion would now duplicate it.","solutions":["Check whether the bundle was already ported: search root pyproject.toml for 'lfx-<bundle>' in the bundle-deps, bundle-sources and bundle-members marker blocks — if all three entries exist, the port is done and you can skip patching.","If the reference is a stale leftover from an aborted run, remove the lfx-<bundle> lines from the three marker blocks and re-run the script.","Run without --apply first to preview planned actions and confirm which steps remain."],"exampleFix":"# before: re-running port_bundle.py --apply for an already-ported bundle\n# after: verify entries then skip\n# grep 'lfx-mistral' pyproject.toml  -> present in deps/sources/members? port complete; no action needed","handlingStrategy":"validation","validationCode":"import re, sys\nfrom pathlib import Path\nbundle = \"mistral\"\ntext = Path(\"pyproject.toml\").read_text()\nif f\"lfx-{bundle}\" in text:\n    deps = f'    \"lfx-{bundle}>=0.1.0\",' in text\n    srcs = f\"lfx-{bundle} = {{ workspace = true }}\" in text\n    members = f'    \"src/bundles/{bundle}\",' in text\n    print(f\"already referenced: deps={deps} sources={srcs} members={members}\")\n    sys.exit(0)  # treat as done, skip the patch step","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run port_bundle.py without --apply first to preview which steps remain.","Track ported bundles in the migration plan/commit history so re-runs are detectable.","Keep the marker blocks (# langflow-extensions:*) as the single insertion point for bundle entries."],"tags":["migration","pyproject","idempotency","cli"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}