langflow-ai/langflow · error · SystemExit
Could not strip ruff per-file-ignore entry for {ri.pattern!r
Error message
Could not strip ruff per-file-ignore entry for {ri.pattern!r}; the regex may not match the current layout. Edit by hand. What it means
As part of porting, port_bundle.py removes the ported provider's per-file-ignore entry (a quoted glob followed by '= [ ... ]') from the ruff config in the root pyproject.toml, using a regex with re.MULTILINE|re.DOTALL. If the substitution changes nothing — the entry's formatting no longer matches the expected 'pattern" = [ ... ]\n' layout — the script refuses to write an unmodified file and tells you to edit by hand, because silently continuing would leave stale lint ignores.
Source
Thrown at scripts/migrate/port_bundle.py:1113
return actions
text = ROOT_PYPROJECT.read_text(encoding="utf-8")
for ri in plan.ruff_ignores:
# Remove the entire entry block (``"<pattern>" = [...]\n``);
# the block may span multiple lines so we anchor on the
# pattern line and consume up to the closing ``]\n``.
# The bracketed body may contain newlines, so use re.DOTALL.
block = re.compile(
r'^"' + re.escape(ri.pattern) + r'"\s*=\s*\[[^\]]*\]\n',
re.MULTILINE | re.DOTALL,
)
new_text = block.sub("", text, count=1)
if new_text == text:
msg = (
f"Could not strip ruff per-file-ignore entry for "
f"{ri.pattern!r}; the regex may not match the current "
"layout. Edit by hand."
)
raise SystemExit(msg)
text = new_text
ROOT_PYPROJECT.write_text(text, encoding="utf-8")
return actions
# ---------------------------------------------------------------------------
# Phase C: workspace + external consumers
# ---------------------------------------------------------------------------
def _insert_before_marker(text: str, end_marker: str, payload: str, *, what: str) -> str:
needle = end_marker
idx = text.find(needle)
if idx == -1:
msg = (
f"Could not locate the {what} end marker ({needle!r}) in "
"pyproject.toml. Re-add the ``langflow-extensions:bundle-*`` "
"marker pair before re-running -- see src/bundles/PORTING.md."View on GitHub (pinned to 976ec789d2)
Solutions
- Open pyproject.toml, find the per-file-ignores entry matching the pattern quoted in the error, and delete that entry (the whole quoted-key = [ ... ] block) manually.
- Then re-run port_bundle.py --apply; the strip step becomes a no-op once the entry is gone.
- Keep per-file-ignore bodies free of inline comments and exotic formatting so the mechanical strip keeps working.
Example fix
# before (pyproject.toml)
[tool.ruff.lint.per-file-ignores]
"src/lfx/src/lfx/components/agentics/**" = [
"RUF012", # keep for now
]
# after (pyproject.toml) — entry removed by hand
[tool.ruff.lint.per-file-ignores]
# (agentics entry deleted; bundle owns its own ruff config now) Defensive patterns
Strategy: fallback
Validate before calling
import re
from pathlib import Path
def per_file_ignore_entry_matches(text: str, pattern: str) -> bool:
block = re.compile(
r'^"' + re.escape(pattern) + r'"\s*=\s*\[[^\]]*\]\n',
re.MULTILINE | re.DOTALL,
)
return block.search(text) is not None or f'"{pattern}"' not in text Prevention
- Keep ruff per-file-ignore entries on a single canonical format: quoted glob, ' = [', flags, ']' — no comments inside the brackets.
- Revert pyproject.toml formatting changes (prettier/taplo) before running --apply migrations.
- When the guard fires, edit pyproject.toml by hand first, then re-run — the script will proceed once the entry is gone.
When it happens
Trigger: Running port_bundle.py --apply when the root pyproject.toml's ruff per-file-ignores section has been reformatted (different quote nesting, inline brackets, comment inside the list, or the pattern string escaped differently) so the generated regex no longer matches.
Common situations: A formatting tool or editor reflowed pyproject.toml between the time the ignore entry was added and the port; hand-edits that changed indentation or added comments inside the bracket body; regex-hostile characters in the glob.
Related errors
- Could not locate the {what} end marker ({needle!r}) in pypro
- Could not read lfx version from src/lfx/pyproject.toml
- lfx-{bundle} already referenced in {ROOT_PYPROJECT.relative_
- error: {source} entries field must be a list
- error: {source} ambiguous_bare_names field must be a list
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/0ec9479fea320077.
Report an issue: GitHub.