Skip to content

fix(parse): preserve multiline link targets - #7642

Open
r266-tech wants to merge 1 commit into
volcengine:mainfrom
r266-tech:codex/markdown-multiline-link-target
Open

r266-tech wants to merge 1 commit into
volcengine:mainfrom
r266-tech:codex/markdown-multiline-link-target

Conversation

@r266-tech

Copy link
Copy Markdown
Contributor

Description

MarkdownParser.parse() raises AttributeError for targets such as [example](./linked.md#section\ncontinued): the outer pattern accepts the target, but the fragment/query splitter returns None. Preserve the original target in that case, so parsing continues and valid neighboring links still rewrite.

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

Fixes #7624. Independently reproduced fragment/query newline inputs. The real directory parser records the affected file as failed and keeps a healthy sibling; downstream server import failure was not verified.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

Add the null check in the existing link owner and parameterize its existing public-parser contract test. No API, storage, or lifecycle contract changes.

Testing

macOS arm64, Python 3.14.10, pytest 9.0.2; isolated synthetic configuration and source SDK/bot paths. Published 0.5.3 native libraries were used for imports; no native service or model ran.

  • Expanded contract test on unmodified 90f4edcede4c: 2 failed, 1 passed, both failures at m.group().

  • .venv/bin/python -m pytest tests/parse/test_markdown_link_rewrite.py -q --no-cov: 46 passed.

  • .venv/bin/python -m pytest tests/parse/test_markdown_apply_layout.py tests/parse/test_markdown_filename_collision.py tests/parse/test_markdown_no_split.py tests/parse/test_markdown_split_token_budget.py tests/parse/test_markdown_local_image_refs.py -q --no-cov: 34 passed.

  • Temporary test_scripts/ probe: 24 real Markdown/directory parser scenarios with LocalParseOutputStore, covering split/no-split, LF/CRLF, crossing a fence, and plain/external controls. All source files emit with the original text and a rewritten valid link; no directory failed_files remain.

  • Ruff lint/format on both changed paths and git diff --check: passed.

  • .venv/bin/mypy --no-incremental openviking/parse/parsers/markdown.py tests/parse/test_markdown_link_rewrite.py: 2189 baseline / 2187 patched errors across imported modules; no new diagnostics after normalizing shifted lines. The two removed errors are the nullable m.group() accesses. Exact original files were checked via --shadow-file in the same environment.

  • Regression coverage added to the existing contract

  • Related tests passed locally

  • Tested on macOS

Checklist

  • Reviewed the full two-file diff
  • Followed repository style

Additional Notes

Seven existing dependency/Pydantic warnings remain. The full suite, server import outcome, and other operating systems were not tested.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Bug]: A Markdown link target that spans lines raises AttributeError and fails the whole directory import

1 participant