Repository navigation
fix(core): 群成员导出只接受 .csv/.xlsx,xlsx 里超长的单元格截到 32000 字 - #1141
Merged
Merged
Conversation
group export-members 和 group export-member-messages 原来只要扩展名不是 .csv 就写成 xlsx 并报告成功(.txt、.json、没有扩展名都是);现在在读数据库之前检查,只接受 .csv 和 .xlsx(不分大小写),其他按用法错误拒绝。成员消息写成 xlsx 时,某条内容(如合并转发的 XML)超过 32767 个字符会让整份导出失败;现在和消息导出一样截到 32000 个字符。截断用 export.rs 新增的 fit_cell,消息导出、成员导出和列表的 xlsx 共用。 fixed #1136 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rustdoc 在 CI 里把公开项链接私有项视为错误。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
做了什么
fixed #1136
group export-members和group export-member-messages有两个问题,这次一起修:.csv就写成 xlsx,并且报告成功(.txt、.json、没有扩展名都是这样)。现在两个函数开头先用MemberTable::of判断格式,只接受.csv和.xlsx(不分大小写),其他按用法错误拒绝:<路径> is neither a .csv nor an .xlsx file; use one of those extensions,中文为「<路径> 既不是 .csv 也不是 .xlsx 文件;请改用其中一种扩展名」。这个检查在服务层、读数据库之前做,所以命令行和serve的子进程路由都会先拒绝。parsed_content为空时取的合并转发 XML),rust_xlsxwriter 就会报MaxStringLengthExceeded,整份导出失败。现在和消息导出一样,截到 32 000 个字符。具体改动:
export.rs:新增CELL_CHARS(32 000)和fit_cell(按字符数截断,不超过时不复制)。列表导出用的export_table_excel也改用它。export_msg/excel.rs:原来的content.chars().take(32000)改用fit_cell,行为不变。services/group.rs:新增MemberTable,两个导出按它分派;xlsx 的数据行改用write_string_with_format加fit_cell。messages_zh.rs:加入新报错的中文。截断处没有加「已截断」之类的标记,和消息导出的做法一致。
验证
export::tests::a_text_longer_than_a_cell_is_cut:按字符数截断(用汉字测),不超过时原样借用;含超长字符串的表格照样能写出。group_e2e:group_exports_take_a_csv_or_xlsx_name_only:.txt、.json、没有扩展名、.csv.bak都是invalid_arguments和退出码 2,且没有写出文件;.CSV写出以 BOM 开头的 CSV,.XLSX写出 zip。a_member_message_longer_than_a_cell_is_cut_in_the_workbook:给合成账号的群里加一条 40 000 字符的消息,导出 xlsx 成功,sharedStrings.xml里最长的连续内容正好是 32 000 个字符。修复前这个导出会失败。usage::a_group_export_to_another_kind_of_file_is_a_usage_error:两个路由的POST都返回 400,命令行(文本和--json两种输出)都是退出码 2,没有写出文件;.CSV、.XLSX能写出。cargo clippy -p weflow-cli -p weflow-core --all-targets -- -D warnings、cargo fmt --check、cargo test -p weflow-cli、cargo test -p weflow-core全部通过。用户可见的行为
有变化:
.csv或.xlsx时,原来静默写成 xlsx,现在报用法错误、不写文件。契约和 API 都没有变。WebUI 传的是服务端选的
.xlsx或.csv路径,扩展名检查不影响它;它现在也不会再因为长消息导出失败。Wiki 的统计与报告和故障排查已同步。🤖 Generated with Claude Code