fix(extract): snap docstring truncation to UTF-8 codepoint boundary (#1017)#1094
fix(extract): snap docstring truncation to UTF-8 codepoint boundary (#1017)#1094harshitaajoshi wants to merge 2 commits into
Conversation
|
Thanks for the reproduce-first fix. The extract_comment_text boundary change is narrow and memory-safe, and the new test is red on the old raw-byte truncation path. I have triaged this with #1017 as a high-priority 0.9.1-rc parsing bug. The diff adds no dependency, network, installer, or workflow surface. Two review changes are needed:
The existing full CI is green; these asks are about keeping every behavior change proved and reviewable. |
…eusData#1017) Signed-off-by: Harshita Joshi <j.harshitaa06@gmail.com>
619b301 to
3ebcf48
Compare
|
Thanks for the review and for catching the byte-offset math. You're right that offset 500 is the final byte of the first kanji, so the pre-fix string ends with the lead byte plus one continuation (an incomplete 2-of-3 sequence), not a lone lead byte from the third codepoint. I've corrected the test comment to document the actual red failure accurately. For the second point, I opted to keep this PR tightly focused on I force-pushed the amended commit and updated the PR description to reflect the narrower scope. Ready for another look when you get a chance. |
Fixes #1017
What does this PR do?
Docstring/comment truncation at
MAX_COMMENT_LEN(500 bytes) inextract_comment_text()cuts at a raw byte offset, which can split a multi-byte UTF-8 character and leave an incomplete byte sequence in the storednodes.propertiesJSON. This breaks any strict UTF-8 consumer reading the SQLite database (e.g. Python'ssqlite3module).This PR snaps the truncation point back to the last complete UTF-8 codepoint boundary in
extract_comment_text().A regression test (
docstring_utf8_truncation_boundary_issue1017) crafts a Go comment with 3-byte CJK characters straddling the 500-byte boundary and validates every byte of the extracted docstring is well-formed UTF-8.Checklist
git commit -s) -- required, CI rejects unsigned commits (DCO, see CONTRIBUTING.md)make -f Makefile.cbm test)ASan hangs on macOS Tahoe 26.5 (Apple Clang 17) for any binary, including a trivial
int main(){return 0;}. All 6294 tests pass when built without sanitizers (SANITIZE="").make -f Makefile.cbm lint-ci)