fix(chunkers): resolve missing protect_urls in SimpleTextSplitter fallback - #2189
Conversation
…nheritance SimpleTextSplitter called self.protect_urls/restore_urls without defining them, which caused AttributeErrors in the file parsing fallback branch when langchain-style splitters were unavailable. Fix: inherit from BaseChunker and synthesize a minimal BaseChunkerConfig so the URL preservation helpers are always available. Closes MemTensor#2115.
🤖 Open Code ReviewTarget: PR #2189 🔍 OpenCodeReview found 4 issue(s) in this PR. 1.
|
✅ Automated Test Results: PASSEDAll tests passed (6/6 executed). memos_python_core/changed-repo-python: 6/6. Duration: 5s [advisory, non-gating] AI-generated tests on branch test/auto-gen-525644d6c2efa3a1-20260731104118: 96/98 passed, 2 failed — these do NOT affect the PR verdict; review the branch manually. Branch: |
Background
Issue #2115 reports that the file-parsing fallback branch fails with
AttributeError: protect_urlswhen langchain-style chunkers are unavailable and the code path falls back toSimpleTextSplitter. The splitter referencedself.protect_urls/self.restore_urlswithout inheriting them from the baseBaseChunker, which is where those helpers are defined.Changes
memos/chunkers/simple_chunker.py:SimpleTextSplitternow inherits fromBaseChunker. The explicitchunk_size/chunk_overlapconstructor is preserved (callers in the read_multi_modal pipeline rely on it). A minimalBaseChunkerConfigis synthesized so that the base class behaves correctly while retaining the existing positional-constructor API.tests/chunkers/test_simple_chunker.py: New tests covering:protect_urls/restore_urlshelpers and round-trip URL preservation.Verification
ruff format+ruff check --fixpass.python3 -m py_compilesucceeds for modified files.Impact
AttributeErrorin the fallback parser pipeline so that document / knowledge ingestion no longer crashes when optional deps are missing.