Repository navigation
Conversation
Adding a long-named PDF with no-split parse produces a temp file shaped like `<41 chars>_<8-char hash>.md` (53 chars); the inline [:50] cut in VikingURI.sanitize_segment then amputated the extension, so the stored URI lost its .md suffix. Split the trailing extension (ASCII alphanumeric, <=5 chars) off before applying the cap, truncate the stem against a whole-segment budget of 50, then rejoin. One fix covers all call sites in tree_builder (resolve_target_uri / finalize_from_temp).
|
Reviewed from the URI-sanitization work we did in #4372 (superseded by #4517) — this closes a real gap the memory-side pass left open on the CLI path, and the test coverage of the exact 1. Truncation can eat the disambiguating hash tail (minor, worth a comment or follow-up). 2. The 50-char cap counts code points, not bytes (pre-existing, surfaced by this change). 3. 4. Nit — extension heuristic edge: Overall: the mechanism is sound and the reserved-stem guard moving to the rejoined name (so |
Replace the no-op multi-dot passthrough test ("a.b.c" never reaches the
>50-char branch) with a 53-char ".md.pdf" case that pins both the
last-dot-run candidate rule and the stem rstrip preventing a "..pdf"
double dot. Document the code-point-based cap (<=200 UTF-8 bytes per
segment), the numeric-tail asymmetry, and the hash-tail tradeoff left
to _sanitize_for_path.
Thanks a lot for the thoughtful review — really appreciate you digging into the boundary cases! All four points are On the hash tail (1): great catch, and it's actually a bit more subtle than I realized — the old inline cut happened On code points vs bytes (2): fair point, and pre-existing as you noted. I've added a comment that the cap is On the multi-dot test (3): you're absolutely right, "a.b.c" never reaches the branch, so that test was just On the numeric tails (4): intentional but undocumented, as you guessed — the tail is kept verbatim either way, so Thanks again also for the kind words on the reserved-stem guard — the _sanitize_for_path extension budgeting is on my |
Adding a long-named PDF with no-split parse produces a temp file shaped
like
<41 chars>_<8-char hash>.md(53 chars); the inline [:50] cut inVikingURI.sanitize_segment then amputated the extension, so the stored
URI lost its .md suffix.
Split the trailing extension (ASCII alphanumeric, <=5 chars) off before
applying the cap, truncate the stem against a whole-segment budget of
50, then rejoin. One fix covers all call sites in tree_builder
(resolve_target_uri / finalize_from_temp).
Description
当资源上传使用参数:no_split 添加长文件名 PDF 时,入库条目丢失 .md 后缀,变成viking://resources/aaaa..._d1e2f 这样的无后缀 URI。
根因:VikingURI.sanitize_segment(openviking_cli/utils/uri.py)对含扩展名的完整文件名做 [:50] 盲切。触发链:
默认(拆分)模式不受影响:temp 产物是目录,.md 在目录内文件上,目录名无扩展名。
Human Involvement
Related Issue
Type of Change
Changes Made
Testing
Checklist
Screenshots (if applicable)
test3 为修复后

Additional Notes