linus-liu-web
a2aeb97a01
fix(gitlab): 分页循环补重复页防护与跳数上限 ( #3841 )
...
projects() 与 tree() 只依据服务端返回的 X-Next-Page 判断是否继续,
该值重复或不前进时循环不会结束:同一页被反复请求、结果切片持续
增长,只能等上层 context 到期。
两条循环改用 trackPage:页码已请求过即返回错误,不静默当作读完;
页数达到 maxPaginationHops 时记警告并返回错误。正常翻页路径不变。
Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-10-08 01:21:37 +08:00
linus-liu-web
b5c74b2dd6
fix(feishu): 多维表格字段分页补重复 page_token 防护与条数上限 ( #3840 )
...
内嵌多维表格的 list-fields 分页循环只判断 has_more 与 token 是否为空:
厂商在 has_more=true 时返回已读过的 page_token,循环就会反复请求同一页并把
同一批字段重复追加进 cols,直到任务 deadline(实测 2s 内 5 万余次请求仍未
返回)。该循环也是同文件里唯一既无去重、又无尺寸上限的分页循环。
- 按同库 wiki 空间/节点与云盘分页已有写法加 seenFieldPageTokens 集合,重复的
非空 token 立即返回 error,不再静默当作读完;
- 补 maxBitableFields = 5000 的条数上限,命中时 Warn 并截断。
测试:重复 token 在第二次出现时报错并停止请求;厂商每页都返回新 token 时在
第 5000 个字段处停止并打 Warn;正常 100 条/页 分页不受影响。
Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-10-08 01:21:31 +08:00
LuckVd
0d3a053eb6
fix(yuque): don't acknowledge failed detail fetches in the incremental cursor ( #3702 )
...
A partial sync recorded each doc's new content_updated_at before fetching
its detail. When a detail request failed after client retries, the cursor
still held the new version, so every later incremental sync treated the
doc as unchanged and never re-fetched it (mixed success/failure batches
persist the cursor; only all-failed batches are aborted).
Rewind the cursor entry to the previously synced version (existing docs)
or drop it (new docs) on detail failure so recovery re-syncs the doc.
Deletion detection is unaffected: currentDocs is set at listing time.
Fixes #3690
Co-authored-by: LuckVd <LuckVd@users.noreply.github.com>
2026-10-08 01:21:23 +08:00
Lukas
98feef38de
fix(chunker): count an escaped pipe as cell text when matching table widths ( #3979 )
...
The header tracker compares a row's column count with the active table
header's to tell a new table from more rows of the same one.
tableRowColumnCount split rows on every `|`, so a cell holding an escaped
pipe (`\|`, which GFM writers such as anydoc emit for a pipe in a cell)
counted as one more column. The tracker took that row for the start of a
new table and dropped the header, so the chunks after it no longer began
with the column names.
Split rows on unescaped pipes only. A pipe after an odd run of
backslashes is text inside the cell, as in GFM.
2026-10-08 01:21:16 +08:00
Yeager0204
e915adb147
fix(chunker): preserve source offsets for table child chunks ( #3969 )
...
Co-authored-by: kwsYegar <331533331+kwsYegar@users.noreply.github.com>
2026-10-08 01:21:08 +08:00
linus-liu-web
a15dfdd941
fix(summary): 坏 JSON 不再冒充文档摘要(截断/畸形 JSON 走失败路径,纯文本兜底保留) ( #3769 )
...
* fix(summary): 坏 JSON 不再冒充文档摘要
非流式文档摘要(Chat)解析失败时原先把模型原文当摘要落库:被 MaxTokens
截断的半截 JSON 会写进 knowledges.description、置 SummaryStatus=Completed
(Asynq 不再重试),同一段文本还会被 buildSummaryChunkContent 索引进 RAG。
- parseDocumentSummaryOutput 改为返回 (*documentSummaryResult, error):
回复形如 JSON(含 markdown 代码围栏)却解析失败、或解析成功但取不到
summary/gist 时返回 errSummaryOutputNotParsable,绝不回退成原文;
非 JSON 的纯文本仍走原有的原文兜底,自定义模板 / 老模型不受影响。
- validateSummaryOutput 复用 chatpipeline.IsLengthFinishReason,
FinishReason 为 length 类取值时返回 errSummaryOutputTruncated。
- 两个 sentinel 经 getSummary 汇入既有失败路径(ProcessSummaryGeneration
的 handleRetryableSummaryFailure、RegenerateKnowledgeSummary 的
handleGenerationFailure):保留旧描述、置 pending/failed 交给 Asynq 重试,
不再以 Completed 落库。
测试:TestParseDocumentSummaryOutput 改为表驱动(截断 JSON、含裸换行 JSON、
无文本 JSON 必须报错且不能把原文当 Summary;纯文本兜底继续通过);
TestValidateSummaryOutput 增加 length / max_tokens 截断用例;
TestGetSummaryRejectsUnusableModelOutput 锁住 getSummary 的错误传播。
* fix(summary): length 截断判定收窄到 JSON 形状回复
非流式文档摘要在校验模型回复时先看 finish_reason:只要 provider 报告
length/max_tokens 就返回 errSummaryOutputTruncated。该判定不认识内容形状,
于是自定义纯文本模板一旦顶到输出预算,就从「截断但可用」变成重试直到
SummaryStatusFailed,与上一提交承诺的「非 JSON 的纯文本仍走原兜底」相反。
- validateSummaryOutput 恢复为只看内容是否为空;新增
validateStructuredSummaryDocument 供 getSummary 使用:先判形状再判
length,只有确实在产结构化摘要(能解析成对象/数组,或 { 开头、[ 开头接
对象/数组/字符串元素)且被预算截断时才返回 errSummaryOutputTruncated。
- 形状判定剥离 UTF-8 BOM、前后空白与一层 markdown 围栏后再尝试
json.Unmarshal;「[文档摘要] …」「[1] …」这类带方括号引用的纯文本不再被
误判成坏 JSON,而截断的 {summary: 与截断的 JSON 数组仍然报错。
- parseDocumentSummaryOutput 同步剥离 BOM:BOM 前缀的截断 JSON 之前会被
当成纯文本落库。
- 表格描述 / 列描述仍走 validateSummaryOutput,截断的描述照旧可索引。
---------
Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-10-08 01:21:01 +08:00
Ankit Jha
27b9ee74a0
fix(storage): use virtual-hosted addressing for Tencent COS through the S3 driver ( #3722 )
...
newS3Client forced path-style for every non-AWS endpoint, so a COS
endpoint such as https://cos.ap-shanghai.myqcloud.com sent requests to
cos.<region>.myqcloud.com/<bucket>/<key>. COS rejects path-style for
buckets created from 2024-01-01, so STORAGE_TYPE=s3 could not reach new
COS buckets, and force_path_style=false had no way to turn it off.
Treat *.myqcloud.com like AWS and use virtual-hosted style. An explicit
force_path_style still wins, and other S3-compatible endpoints keep
path-style.
Fixes #3134
Signed-off-by: Ankit Jha <ankit.jha@tradomate.one>
2026-10-08 01:20:54 +08:00
Perfecto
a8c291c6ff
fix: keep failed data-analysis table loads retryable ( #3745 )
2026-10-08 01:20:48 +08:00
诉说晚秋
7c284e7fc9
fix(faq): 保留克隆状态同步时的正文和索引状态 ( #3993 )
2026-10-08 01:20:39 +08:00
knqiufan
e29301115a
fix(graph): preserve relationship direction and document provenance ( #3950 )
...
* fix(graph): preserve direction and document provenance in graph retrieval
* test(graph): verify live query bounds and seed evidence ordering
* fix(graph): deduplicate expansion using bounded seed identities
* ci: retry upstream scan after missing CodeCC report
2026-10-08 00:48:51 +08:00
AI即世界
afc6cbd502
fix(milvus): validate connections and preserve gRPC resolver defaults ( #3654 )
...
* fix(docreader): preserve gRPC resolver defaults
* fix(milvus): validate connection with SDK handshake
* fix(docparser): preserve gRPC resolver defaults
* fix(milvus): satisfy connection check lint
---------
Co-authored-by: tunan <tunan@ahyk.com>
2026-10-08 00:48:45 +08:00
Mohamed Arbi
9fa9e7c29d
fix: use consistent qdrant env settings ( #3960 )
...
* fix qdrant env settings
* fix test formatting
2026-10-07 23:59:56 +08:00
linus-liu-web
9490035f15
fix(agent): 图谱查询的三处截断必须可见,模型不再把子图当全集 ( #3885 )
...
query_knowledge_graph 有三处静默上限:返回关系 30 条、每个知识库抓取的
证据 chunk 10 条、送进图谱存储的实体词 8 个。命中上限后既不计数也不提示,
输出还按截断后的长度报告 "Found N relations",读起来就是"该实体的关系就
这么多"。模型据此把被砍过的子图当作实体的完整邻域作答,漏答或得出与图谱
事实不符的结论,且没有任何信号提示它应当收窄实体。同一仓库的图谱存储层
(neo4j/repository.go 的 graphSearchMaxRows 告警)已经把"截断必须可见"
写成明确要求,工具层没有遵守。
改动:
- 关系去重后继续计数,Data 增加 relations_total / relations_omitted;
- 证据 chunk 边取边计数,Data 增加 graph_chunks_total / graph_chunks_omitted
(未接 chunk 仓库、抓取失败都不计入,避免把错误报成截断);
- 被上限丢弃的查询词计数进入 Data(query_terms_total / query_terms_omitted);
- 命中上限时 Output 追加 "=== ⚠️ Truncated ===" 段并给出收窄建议,主行改为
"Found 30 of 42 relations";未命中上限不输出任何内容,沉默只表示没有丢弃;
- modelcontext 的 <retrieval> 视图补 <graph_truncated .../>:模型在有 chunk
行时读的是重建视图,标记只写 Output 到不了模型。
上限数值、去重语义与检索行为不变,只让截断可见。
Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-10-07 23:59:50 +08:00
linus-liu-web
5648d24a93
fix(retriever/milvus): CopyIndices 按映射分块读源行,去掉会静默漏向量的 offset 窗口 ( #3883 )
...
CopyIndices 用 offset/limit 窗口遍历源知识库:offset 是"跨请求保持不变的结果
顺序"上的游标,而普通 query 不承诺这个顺序(结果按 segment 合并,且本次拷贝
每页都在往同一个 collection 写目标行),窗口一漂移就会跳过落在新窗口之前的行、
并重读被窗口退回的行;终止条件"短页即结束"(count < batchSize)又把因此提前
出现的短页当成读完了,剩余向量被静默丢掉,函数仍然返回 nil。用进程内假 Milvus
(gRPC 服务 + DisableConn,走真实 client.Query/Upsert 路径)在每次写入被确认后
旋转结果顺序复现:200 个源 chunk 全部返回成功、日志 total copied: 200,但
3 个 chunk 的向量从未写入目标库、另有 3 个被写了两遍(offsets=[0 64 128 192])。
改成按映射里的源 chunk ID 分块读:谓词 = knowledge_base_id 相等 + chunk_id in
(本批 64 个),读到的行集合由谓词唯一确定,没有游标可漂。拷贝的集合与改动前一致
(原先读到但不在映射里的行本来也会被跳过),只是不再按 offset 前进。同一文件的
chunk_id 批量读(updateChunkEnabledStatusInCollection、BatchUpdateChunkTagID)与
SQLite 版 CopyIndices 用的就是这个形状。
回归用例用进程内假 gRPC Milvus 注入跨页顺序漂移:去掉本修复该用例必失败
(missing=[target-chunk-064 target-chunk-129 target-chunk-194]、
repeated=[target-chunk-000 target-chunk-001 target-chunk-002] 而函数返回 nil),
修复后 offsets 全为 0、无缺失无重复。
Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-10-07 23:59:44 +08:00
linus-liu-web
5f5093b9f7
fix(retriever): Qdrant/Milvus 关键词检索整批失败返回 error,不再当成「没有匹配」 ( #3847 )
...
* fix(retriever): Qdrant/Milvus 关键词检索整批失败不再当成没有匹配
Qdrant 与 Milvus 的 KeywordsRetrieve 逐个 collection 检索,单个 collection 失败只降级成
一条日志后 continue。循环结束后按结果条数分支:全部 collection 失败与确实零命中都会打印
"No keyword matches found"、返回空结果与 nil error。上层只看第二个返回值,据此判定知识库
没有相关内容,用户与模型都无法区分"没有这个词"和"检索没有执行成功"。
改为在循环内累计匹配到的 collection 数与失败的 collection 数,全部匹配 collection 都失败
时返回带底层原因的聚合 error,例如
"qdrant keyword search failed in all 2 matched collections: <cause>"。计数放在 collection
名前缀/维度匹配之后,名字不匹配的 collection 不参与统计;匹配到的 collection 为 0 时维持
原行为,不报错。Milvus 的三处 continue(Search / convertResultSet /
buildMilvusIndexResults)全部计入,另有两处同样会跳过 collection 的失败路径(analyzer mode
探测、过滤器构建)一并计入,这三处的日志补上 collection 名。
部分失败时不再打印结论性的 "No keyword matches found":有结果时改为提示结果不完整,无结果
时说明有多少个 collection 应答过、多少个失败;只有本次调用没有发生任何错误时才继续打印该
结论。RetrieveResult.Error 保持原样(仓库内没有读取方),改动面最小、语义最清晰的暴露方式
是整批失败返回 error。
回归测试:
- Qdrant(repository_test.go):假 Qdrant gRPC 服务让 Scroll 全失败时返回 error 且不打印
结论日志;只有一个 collection 失败时结果与 nil error 不变;全部成功且零命中时仍返回空结果
+ nil error 并保留结论日志。
- Milvus(新增 keywords_test.go):*client.Client 没有接口缝隙,改用进程内 Milvus gRPC 假
服务(ShowCollections / DescribeCollection / Search)覆盖同样三种情形,走真实 Search 与
结果转换路径。
- go.mod:milvus-proto 由新测试直接导入,去掉该依赖的 // indirect 标记。
反向验证:把两个 repository.go 改回原样后,两条"全部失败"用例分别以
"all-collections failure must surface as an error, got <nil>" 与
"An error is expected but got nil" 失败,部分失败与零命中两条用例保持通过;随后逐字节还原
修复。
* fix(retriever): 关键词检索部分失败随结果一起暴露,不再被当成完整结果
Qdrant/Milvus 的 KeywordsRetrieve 逐 collection 检索,部分 collection 失败时保留其余
collection 的结果并返回 nil error。上层拿到的是"结果 + nil error":既不知道少了几个
collection 的内容,也没有任何读取方,RetrieveResult.Error 因此长期是死字段。上一个
commit 只处理了"全部匹配 collection 都失败",部分失败仍然静默降级,模型与用户看到的
都是不完整结果。
让部分失败沿着结果走完这条链路:
- repository(qdrant/milvus):部分失败时把
"… keyword search failed in N of M matched collections: <cause>" 写进
RetrieveResult.Error —— 结果照常返回、调用级 error 仍为 nil;全部失败仍是调用级
error,真正的零命中仍然 Error == nil;
- CompositeRetrieveEngine:读取每个结果集的 Error 并聚合,连同结果一起返回
("retrieve returned partial results: …");引擎级 error 仍然丢弃全部结果,
all-or-nothing 策略不变;
- retrieveFromStores(该接口的唯一消费方):结果与 error 同时非空即"部分失败",打出
带 store group 与原因的 WARN 并保留结果返回 —— 既不会把降级 store 升级成整次搜索
失败,也不会让上层把不完整结果当完整结果;
- matched == 0(没有任何 collection 匹配 base name)单独打一条 Warn,与"检索成功但
零命中"区分开;
- milvus/repository.go 的 allFields 块按 gofumpt 重排,四个包 gofumpt -l 干净。
回归测试:
- qdrant/milvus:部分失败(有命中 / 零命中)结果集带 Error 且调用 error 为 nil;全部
成功零命中仍 Error == nil 且保留结论日志;全部失败仍是 error;matched == 0 打专属
Warn 且不发任何 Scroll/Search;
- CompositeRetrieveEngine:结果集带 Error → (结果, error) 同时返回;结果集完整(含零
命中)→ 无 error;引擎级 error → 丢弃全部结果;
- retrieveFromStores:单 store / 多 store 部分失败都打 WARN 且保留结果,完整零命中不
打 partial 日志,引擎级 error 仍然失败。
反向验证:去掉四个源文件的可见性改动后,17 条新/改用例中 9 条失败(qdrant 3、milvus 3、
composite 1、retrieveFromStores 2),钉住"行为不变"的 8 条保持通过;还原后 diff 与
改动前逐字节一致。
---------
Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-10-07 23:59:38 +08:00
linus-liu-web
f9eeb8dc85
fix(retriever/es): _bulk 的 per-item 失败不再被吞,全部被拒时 BatchSave 返回错误 ( #3842 )
...
Elasticsearch 受理 _bulk 请求即返回 HTTP 200,单个文档的写入失败只体现在响应体的
errors 与 items[].<op>.error。v8 把响应对象整个丢弃,只看传输层错误;v7 读了响应,
却只把结论降级成一行告警,响应体解析失败同样返回 nil。两个驱动的 BatchSave 因此在
文档被逐条拒绝时仍返回成功:调用方不标记 failed、不清理 chunks,阶段数据照写全部
条数,文档从此搜不到也不会重试。触发条件都是常规运维事件——mapping 不符、磁盘水位
只读、index 缺失、写压力下的 item 级拒绝。
修复:
- v8 接收 typed bulk 响应对象,resp.Errors 为真时遍历 resp.Items 聚合失败项。
- v7 把 countBulkErrors 的结论从"仅告警"升级为返回错误;响应体解析失败同样返回
错误,不再把结果未知当成成功。
- 错误信息只带文档 _id 与有界的 error.type,最多摘要 5 条,失败条数覆盖全部失败
项;error.reason 可能含文档正文,只写 debug 日志。写法对齐 OpenSearch 驱动既有
的 inspectBulkResponse。
回归测试(v7/v8 各一份,httptest 假 ES + 真实构造函数):全部被拒返回错误、部分
失败返回错误且能看出失败条数、全部成功返回 nil;v7 另覆盖响应体损坏。断言同时确认
返回的错误不含 error.reason 中的文档内容。
反向验证:把两个驱动改回原实现后,新增用例 v7 失败 3 条、v8 失败 2 条;恢复修复后
全部通过。
Fixes #3832
Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-10-07 23:59:32 +08:00
linus-liu-web
a8a2c17b89
fix(sqlite): 索引行写入失败不再被丢弃,BatchSave 回滚而不是留下「主行在、索引行不在」 ( #3843 )
...
* fix(sqlite): 索引行写入失败让 Save/BatchSave 报错并回滚
Lite(DB_DRIVER=sqlite)的 vec0 / FTS 索引行 helper 丢弃 Exec 返回值:
BatchSave 的事务末尾无条件 return nil,于是 chunk 主行提交而索引行缺失,
Save/BatchSave 仍报成功,向量与关键词两条检索路径都静默漏召回;CopyIndices
的 copyVec 同样可能报成功而向量行没有复制过去。
- insertVec / syncFTS5Insert / copyVec / deleteRowsAndVecs 返回 error,在
BatchSave(事务内)与 CopyIndices 的调用点检查并上抛:事务回滚,
BatchIndex 报错后走 knowledge_process.go 既有的清理与 failed 标记路径;
删除路径在索引行删除失败时不再删除主行。
- ensureVecTable 校验同名对象确实是 vec0 表之后才缓存"已就绪",失败上抛
(BatchSave 与 vectorRetrieve);向量写失败时清掉该维度的缓存,下一次写入
重新建表,而不是被永久短路。
- initFTS5 返回 error,并把建表与回填放进同一个事务(半回填的索引会静默丢
召回);驱动未编译 fts5 模块(上游 go test 不带 -tags sqlite_fts5)时只
记录一次并跳过关键词写入,而不是让每次入库失败;Lite 发布构建始终带该 tag。
新增 index_write_errors_test.go:覆盖 vec0 / FTS 表缺失、vec0 维度不匹配、
同名对象占位、索引删除失败、CopyIndices 向量复制失败,以及正常路径与无 fts5
模块构建。把修复改回原样后,其中 6 个用例必失败。
Fixes #3833
* fix(sqlite): CopyIndices 行复制失败累计上报,不再 Warn 后跳过
克隆/搬运知识库时逐行 Create 失败原先只记 Warn 并 continue:目标库会缺
主行/索引行却仍报成功。现改为逐行累计错误,FTS 与向量复制失败同样累计
而不是遇到第一条就返回,最后 errors.Join 交给调用方;错误里带源/目标
chunk id 便于定位失败行,不含正文。调用方沿用既有 rollbackIndices 回滚
与 failed 标记路径。
新增回归用例:触发器拒单行 -> 调用方拿到可定位到该行的错误、同 chunk 的
其它行照常复制;DROP FTS 表 -> 错误带上表和 chunk id 且向量行仍写入。
---------
Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-10-07 23:59:26 +08:00
linus-liu-web
72b8a106c7
fix(sqlite): 检索后端批量更新索引副本失败不再吞掉错误 ( #3768 )
...
* fix(sqlite): 检索后端批量更新索引副本失败不再吞掉错误
Lite(DB_DRIVER=sqlite)的 BatchUpdateChunkEnabledStatus 与
BatchUpdateChunkTagID 逐条执行 Update 后丢弃 gorm 的 .Error 并无条件
return nil:索引副本更新失败被吞,接口仍报成功。
服务层是"先写权威 chunks 行(成功)→ 再同步检索索引副本"
(knowledge_faq.go:877-889 等),而检索只读索引副本
(lite_embeddings.is_enabled / tag_id)。因此索引 UPDATE 失败
(SQLITE_BUSY、磁盘满)或未命中任何行时,接口返回成功、UI 显示新标签
或已停用,但按新标签过滤搜不到、刚停用的条目仍会被召回。postgres 后端
同名函数在 result.Error != nil 时本就 return result.Error,sqlite 与之
对齐:逐条检查 .Error,非 nil 时用 fmt.Errorf 包装 chunkID 与操作名
返回。postgres 不把 0 行当错误(仅记录 RowsAffected 日志),故此处也
不引入"0 行即错误"。
新增 batch_update_test.go:用 DROP TABLE 与触发器构造必然失败的
UPDATE,断言返回非 nil 错误(修复前返回 nil),并覆盖成功路径。
注:本条是 sqlite 后端"执行了但吞掉错误",与 #3426 的 weaviate 后端
"未真正执行操作"属于不同后端的不同机制。
* fix(sqlite): 批量更新索引副本累计错误后汇总返回,并让 0 行可见
BatchUpdateChunkEnabledStatus / BatchUpdateChunkTagID 逐条执行 UPDATE,上一版
改成"首个错误即 return":语义从"尽力更新全部"退化成"只更新一个前缀",而前缀
取决于 map 迭代顺序。同类后端不是这么做的:milvus 与 qdrant 都是把每条错误
累计进切片后 errors.Join 并继续跑完。因此改为循环内累计错误、跑完全部行,最后
errors.Join 返回;错误信息仍带 chunkID 与操作名,调用方观察到的"失败即 error"
不变。
另外上一版只检查 .Error,没有看 RowsAffected:"索引 UPDATE 匹配 0 行"在
sqlite 上依然完全不可见。0 行仍不算错误(索引副本允许落后于权威 chunks 行,
postgres 后端同样只记日志),但现在会打一条 Warn,带表名、列名与 chunk_id,
不含正文内容。
测试(internal/application/repository/retriever/sqlite/batch_update_test.go):
- ReportsEveryFailingStatementInBatch:触发器让批内 5 条全部失败,断言
errors.Join 中 5 个 chunk 都出现、失败消息出现 5 次。首错即 return 时只有
1 条,用例必失败。
- KeepsUpdatingAfterStatementFailure:批内 chunk-3 失败时 chunk-4/5 仍被更新;
断言落在结果行而非"第几条",因为 map 迭代顺序随机。
- WarnsWhenStatementMatchesNoRow:命中 0 行仍成功返回,但日志里有带
lite_embeddings.<列名> 与 chunk_id 的 Warn。
顺带补 gofumpt 要求的函数间空行(main 上既有的格式差异),使该文件 gofumpt 干净。
默认构建与 -tags sqlite_fts5 两种构建下
go test ./internal/application/repository/retriever/sqlite/... -count=1 均通过。
---------
Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-10-07 23:59:19 +08:00
xxxxx
0ec945fe5d
fix(dataset): use supported default QA model ( #3965 )
2026-10-07 23:54:36 +08:00
linus-liu-web
402f69832e
fix(notion): 查询撞厂商上限被截断时不再静默,截断轮次不下发删除 ( #3845 )
...
* fix(notion): 查询撞厂商行数上限不再静默截断,截断轮次跳过删除判定
Notion 单次 data source 查询最多返回 10,000 行。撞到上限时厂商把 has_more 置为
false,并在响应里带 request_status.type == "incomplete"
(incomplete_reason = "query_result_limit_reached"),而 connector 只认
has_more、不解析 request_status,于是"被截断"与"读完"在代码里完全同形:
- QueryDatabaseAll 返回 err == nil、10,000 条记录,日志照常打
"database <id> (<title>): 10000 records",同步看起来完全成功;
- 增量同步里,本轮查询未返回、又没被 /v1/search 带出来的行,会被当成源端已删除
下发 IsDeleted。开启删除同步时,已在库的文档连同向量被真实删除,而同步日志仍
显示成功。
改动:
- types.go:paginatedResponse 增加 request_status 解析(notionRequestStatus /
isIncomplete)。
- client.go:paginatePages 在每一页反序列化后判定 incomplete(厂商文档要求逐页
检查,标记可能出现在最后一页之前),命中即返回可识别的
errQueryResultTruncated,连同该页已取回的行,调用方既能拿到部分数据,也不会
再把缺失行当作"源端已删除"的证据;QueryDatabaseAll 遇到截断不再走
"当作 database_id 再解析一次"的回退,避免重复同一次受限查询并把截断错误埋在
查找失败后面。
- connector.go:截断信号经 queryDatabaseRecords 传到
fetchDatabaseIncremental / fetchDatabase / fetchPage,本轮只要出现过截断,删除
判定整体跳过(与 #3682"发现请求失败即中止、不删"同一取向);计数与日志改为
带截断标记的 Warn,让"同步成功但文档数偏少"可解释。
新增回归测试 internal/datasource/connector/notion/query_truncation_test.go:截断
(含中途页截断)必须返回哨兵错误且不重试、端到端不产生 IsDeleted、子数据库路径
同样传出截断;同时锁定正常 has_more=false 无 request_status 的结果集行为不变
(正常读完仍照旧判定删除)。反向验证:去掉逐页判定后 4 条断言失败的用例失败、
3 条保护性用例通过,随后逐字节还原。
按 created_time 开新窗口的分页改写(厂商大数据源食谱)改动面较大,留作后续改动:
本次修复只保证截断可见、不误删;超过上限的记录仍不会被这批同步收进知识库。
* fix(notion): 数据源查询按 created_time 开窗口,超过 10,000 行的记录也能取全
Notion 单次 data source 查询最多返回 10,000 行:撞限时厂商把 has_more 置为 false,
并带 request_status.type == "incomplete"(incomplete_reason ==
"query_result_limit_reached")。本 PR 的前一版让截断可见、不再误删,但被截断的记录
仍然进不了知识库——一次查询的上限就是一次查询的上限,只跟着 next_cursor 走永远读
不到第 10,001 行。
按厂商"大数据源"食谱改为时间窗口分页(用 created_time,不用会随编辑移动边界的
last_edited_time):
- types.go:notionPage 增加 created_time,作为窗口边界。
- client.go:数据源查询改走 queryDataSourceAll / queryDataSourceWindow。每个窗口都
带 sorts: [{timestamp: created_time, direction: ascending}],窗口内继续按
next_cursor 翻页;只要该窗口任意一页带 incomplete 标记(厂商明确要求逐页检查,
标记可能出现在最后一页之前),就用 filter.created_time.on_or_after = 本窗口最后
一行的时间戳开下一个窗口,累计结果按行 ID 去重(相邻窗口共享边界行,边界行只会
入库一次)。窗口推进必须严格前进:没有任何行带 created_time,或窗口最后一行的时间
戳没有超过窗口起点(同一 created_time 的行数超过单次查询上限)时停止续窗、打 Warn
并返回 errQueryResultTruncated,绝不原地重查。每次续窗都打一条 Warn,截断仍然留痕。
- connector.go:queryDatabaseRecords 的截断日志改为"撞上限且窗口无法推进";"截断轮次
跳过删除判定"的行为保持不变(现在的截断只可能来自无法推进的窗口)。
回归测试:新增 query_windowing_test.go,用按请求里的窗口过滤条件返回数据的假服务端
覆盖跨 4 个窗口取全 5 行并按行 ID 去重、同一窗口内的重复行去重、incomplete 标记落在
非末页时仍然开新窗口、未撞上限的正常路径行为不变(request_status 为 complete 与完全
缺失两种形态)。query_truncation_test.go 改写为:窗口无法推进(同一 created_time 超
限、行不带 created_time、空窗口仍 incomplete)时停止并告警、端到端不产生 IsDeleted;
另加窗口取全后仍照常判定源端真实删除的用例,防止"一有窗口就不再删"的过度修复。
反向验证:把窗口续读改回"撞上限即中止"后,窗口取全相关用例全部失败(QueryDatabaseAll
报 "vendor limit reached ... 2 records fetched",端到端漏报 r4 的删除),"正常路径行为
不变"与"截断不误删"的用例继续通过,随后逐字节还原。
---------
Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-10-07 23:54:08 +08:00
hailongzhao
bccb4b151b
fix(embed): 内嵌网页只传图片不输入文字时不再返回 400
...
内嵌网页的输入框允许只带图片或附件就点击发送,但 CreateKnowledgeQARequest.Query
带有 binding:"required",parseQARequest 也拒绝空 query,于是只传图片直接返回
400 "Query content cannot be empty"。
入口处理:去掉 binding:"required";文字为空但带有内联图片数据或内联附件时,
用 types.UploadOnlyQuestion 生成一句替用户提问的问题(中文界面为「请根据我
上传的内容回答。」,其他语言为英文),交给模型、检索、标题、会话历史索引、
追问建议和记忆使用。只有 URL 的图片不算上传,因为客户端传入的图片 URL 会被
清掉;预上传的 attachment_ids 也不算,这类文件在流开始后才解析,可能失败或
超时,届时模型没有任何内容可答。其余空 query 仍返回 400。
存储与显示:qaRequestContext 新增 userInput,保存用户消息时只存用户实际
输入,只传图片时为空,刷新后与发送当下显示一致;query 仍是给模型的问题。
steer 追问复制上一轮的请求上下文,显式设置 userInput,避免在只传图片的一轮
之后把追问存成空消息。
会话历史:文字为空但带图片或附件的用户消息,在两处历史重建里补上同一句
问题。知识问答流水线(loadAndProcessHistory)原先会整轮丢弃;Agent 历史
(LoadAgentHistory)原先会发出空的用户消息,被 SanitizeMessages 剔除后
前后两条回答被合并。
去掉 binding 标签会让 gofmt 重新对齐整个 CreateKnowledgeQARequest 的行尾
注释,这些既有的超长行因此会被 PR 的增量 lint 视为新增。按仓库惯例把字段
注释移到字段上一行(注释文字不变,swagger 描述不受影响),并把 Go 字段
KnowledgeIds 改名为 KnowledgeIDs(JSON 名仍是 knowledge_ids,接口不变)。
同步更新 swagger 文档,query 不再是必填字段。
2026-09-30 15:26:51 +08:00
wizardchen
75fc0ad159
feat(docparser): upgrade AnyDoc to 0.2.4 and parse assets once
2026-09-30 15:25:01 +08:00
linus-liu-web
1dbe9d0c1a
fix(gitlab): 仓库文件下载补体积上限,超限报错而不是无界读入 ( #3887 )
...
* fix(gitlab): 仓库文件下载没有体积上限,超限改为显式报错
getRaw 直接用 io.ReadAll 缓冲整个 blob,get/getPage 的 JSON 读取同样无界。
GitLab 的 tree/compare 接口不返回 blob 大小,下载处是唯一能拦的地方,所以
同步一个音频或大 PDF 就会把一个完整 blob 读进进程内存。
对齐兄弟 connector(钉钉 16MiB JSON 上限、飞书 512MiB 下载上限):
- maxJSONResponseBytes(16 MiB)用于 get/getPage;
- maxRawFileBytes(512 MiB,与飞书 maxFeishuDownloadBytes 对齐)用于 getRaw;
- base64 回退走 getCapped,其请求体是 base64 后的 blob(约 4/3)加信封。
超限返回错误而不是截断:截断的正文会被当成完整文档入库。非 2xx 状态先于
读取判定,避免超大错误页把真实状态码盖掉。
* fix(gitlab): 将 compare 响应上限与元数据分开
compare 正文包含完整提交和 patch,沿用 16MiB 元数据上限会中断增量同步且游标无法前进。超限错误改为带上未编码的仓库路径。
---------
Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-30 14:33:15 +08:00
linus-liu-web
b71b31c897
fix(ima): 笔记正文被清空后旧正文仍留在知识库
...
fetchNote 在正文为空时返回 fetchSkipped,walk 只把该 key 记进增量游标而
不产出任何 item。于是重新读到一篇已被清空的笔记时,入库层收不到「内容变
空」的信号:旧正文既不会被替换,游标还把它记为已同步。
Notion(b9be7d0d)与 Confluence 早就是这个写法:正文为空时仍然产出只有
标题的 markdown,让入库去替换旧正文。这里对齐同一写法,空正文改成
"# <title>\n" 照常走 fetchOK。
2026-09-30 13:43:55 +08:00
linus-liu-web
2ec1774623
fix(auth): 令牌写入失败不再当成登录成功,查询失败不再谎称已撤销
...
generateTokensForTenant 把两次 CreateToken 的错误都丢给了 `_`,然后照常返回
token 对。签发出去的 JWT 签名正确、语法合法,但 auth_tokens 里没有行,
ValidateToken / RefreshToken 在下一次请求就把它拒掉——用户看到的是"刚登录就掉
线,反复登录都一样"。更糟的是校验侧把"查不到"和"已撤销"合并成同一个分支:
if err != nil || tokenRecord == nil || tokenRecord.IsRevoked {
return nil, 0, errors.New("token is revoked")
}
于是真实的插入错误既没有落日志,也被贴上了一个从未发生过的原因("token is
revoked"),把排查方向引向"会话被踢"。触发条件只是常规基础设施抖动:语句超时、
连接池耗尽、连接被重置。
同文件的对照写得很清楚:SwitchTenant 对同类写入 `return fmt.Errorf(...)`("a
200 response is also a durable landing-preference update"),Logout 直接返回
RevokeTokensByUserID 的错误;这两处是全文件唯一"写完不检查"的地方。
改动:
- 两次 CreateToken 都检查错误,失败即 `persist access token/refresh token: %w`
返回,保证"登录成功"一定对应已持久化。正常路径不变:两行都写成功才返回令牌对。
- ValidateToken / RefreshToken 把查询错误与"已撤销/不存在"拆开:查询失败按基础
设施错误上报(`look up token: %w`),`IsRevoked` 仍然报 "token is revoked",
不再用一句假话掩盖查询失败。
新增用例(internal/application/service/user_token_persistence_test.go):
- 写入失败时 Login 必须 Success=false 且不下发任何令牌;
- 访问令牌/刷新令牌任一写入失败都不得返回令牌;
- 正常路径回归:两行都落库、access token 随后能通过 ValidateToken;
- 查询失败如实上报(errors.Is 命中原始错误,且不含 "token is revoked");
- 真的被撤销时 "token is revoked" 仍然保留。
L2 复现(假 token repo 返回写失败):修复前 Login 返回 success=true、
tokenIssued=true,紧接着用该 token 请求得到 "token is revoked";修复后 Login
返回 success=false、message="Login failed"、不下发令牌。去掉 user.go 的改动后
新增用例 5 个子用例全红,两条正常路径回归用例仍绿。整个 service 包
`go test ./internal/application/service/` 通过,scoped golangci-lint 0 issues。
2026-09-30 13:40:51 +08:00
lizijing98
dba9127558
docs(api): 补充模型复制接口说明
2026-09-30 13:34:18 +08:00
hailongzhao
176aa0d02b
fix(sandbox): build real arm64 sandbox images and ship arm64 Cube variants
...
The global `ARG TARGETPLATFORM=linux/amd64` in Dockerfile.sandbox overrode
the per-platform value BuildKit injects, so the multi-platform CI build ran
every platform on the amd64 rootfs and only relabeled the arm64 config.
The published arm64 entries of main, latest and main-desktop are byte-for-byte
the amd64 layers. The stage-level `ARG TARGETARCH=amd64` had the same effect,
so the cube "amd64 only" guard could never fire.
- Declare TARGETPLATFORM without a default and fall back to linux/amd64 in
FROM only when it is empty (legacy builder).
- Fail the runtime stage when the rootfs architecture differs from
TARGETARCH.
- cubesandbox-base:2026.16 publishes linux/arm64 as well, and Cube runs on
arm64 bare-metal KVM (PVM stays x86_64-only). Follow TARGETPLATFORM for
cube-base, replace the amd64-only guard with an envd-vs-rootfs check, and
build cube / desktop-cube for linux/amd64,linux/arm64 in CI and
build_images.sh.
2026-09-30 13:34:01 +08:00
lyingbug
5225edc0f7
feat(auth): 新增仅限邀请注册档位 ( #3900 )
...
* feat(auth): add invitation registration mode
* fix(auth): resolve registration mode lint errors
2026-09-30 13:32:55 +08:00
LL_Ricky
9842e51d40
fix(frontend): 修复复制模型时模型名称被改写的问题 ( #3830 )
...
* fix(frontend): 修复复制模型时模型名称被改写的问题
* fix(model): preserve model name and credentials when copying a config
Copying rewrote the upstream model name and posted redacted parameters, so the duplicate could not authenticate. Clone the stored row, cap the display name, and skip a new download when the local model is already active.
* fix(lint): clear new golangci-lint findings on model copy
Check c.Error results, wrap the long test line, and format the stub. The pull request lint range also includes the new HTTP error test, whose unused request parameter failed revive.
---------
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-29 19:32:08 +08:00
dajiaohuang
0c6b30cfa7
fix(docs): spawn nested npm through Node on Windows
2026-09-29 17:19:25 +08:00
dajiaohuang
75d2c1b583
fix(frontend): normalize style guard paths
2026-09-29 17:16:54 +08:00
hailongzhao
f46c990567
fix(embed): 开启 Host context 后点击追问建议不再返回 400
...
嵌入渠道调用 WeKnora.setContext 后,前端 buildQueryWithHostContext 会把
query 包成 "[Host context]\n<k: v 行>\n\n<问题>" 再发出,而
ValidateAttribution 用 TrimSpace 后的全文与建议文本做精确比较,带信封的
query 永远不相等,于是每次点击追问建议都返回 400
"invalid suggestion attribution"。
后端:新增 queryMatchesSuggestionText,精确匹配失败时识别 host context
信封——要求以 "[Host context]\n" 开头、信封内容非空、以空行结束,且空行后
紧跟的正好是被点击的建议文本。宿主传入的 value 可以含换行甚至空行,所以用
建议文本从尾部锚定切分,而不是取第一个 "\n\n"。不校验信封里每行的 key/value
形态:前端对 key 不做约束(带空格、空 key、value 以换行开头都会原样拼进去),
校验只会误伤合法 context,而归因只用于统计点击与实际发送,不涉及权限。
在信封与问题之间或问题之后夹带额外文本、任意前缀、空信封仍会被拒绝。
前端:handleFollowUpSelect 原先在回复生成中点击建议时也会写入待发送归因,
但跳过发送,归因会泄漏到用户下一条手动输入的消息上,同样导致 400。改为只在
真正发送时写入归因,click 事件照常上报。
Fixes #3820
2026-09-29 12:16:46 +08:00
linus-liu-web
1912ba26c5
test(weaviate): 让并发建表的用例真的每个 worker 都去创建,消掉随机失败
...
TestEnsureCollectionToleratesConcurrentCreation 用 barrier 让 8 个 worker 都先探到
"class 不存在",再一起冲创建,最后断言 server.creates == workers。但假服务器的 GET
分支是「先等 barrier、再采样 s.exists」:barrier 一放开,赢家的 POST 可能已经把
exists 置为 true,排在后面的 worker 采样到"已存在",就在创建之前返回了,从来没去
尝试创建。实际创建数取决于调度(本地 100 次里挂 1 次;CI 上是 4 或 6),断言于是
随机失败 —— main 自己的 CI 与多个 PR 都挂在这条上。
把采样挪到 barrier 之前:每个 worker 读到的是它到达时的状态(此刻必然为 false),
8 个创建请求全部到达服务端,断言稳定。测试注释里写的意图本来就是"让每个 worker 都
看到 class 缺失",这里只是让实现与意图一致。
只改测试,不碰生产代码。
2026-09-29 01:32:23 +08:00
linus-liu-web
e39043f34b
fix(repository): 关键词 LIKE/ILIKE 检索补显式 ESCAPE,修复 Lite 上静默漏结果
...
SQLite(Lite 版所用数据库)没有默认的 LIKE 转义字符,而 Postgres 的默认转义字符是
反斜杠。escapeLikeKeyword / escapeLikePattern 会把关键词里的 %、_、\ 转义成 \%、\_,
但只有在 SQL 中显式声明 ESCAPE 时才有意义:缺少 ESCAPE 时 SQLite 会把反斜杠当成普通
字符,于是任何含 _ 或 % 的关键词(如 IMG_2534、100%)都匹配 0 行——不报错、不打日志,
total 同样为 0,前端只显示"暂无数据"。Postgres 因默认反斜杠转义而表现正常,所以问题
只在 Lite / SQLite 上静默出现。
本次修改统一在 LIKE 表达式后补 ESCAPE,并把 escape 字符作为参数传入(Postgres 的
ILIKE 分支同样处理),写法对齐 message.go / message_artifact.go / chunk_image_assets.go
中已有的正确站点,转义字符复用 knowledge.go 既有的 likeEscapeChar 常量。
修复站点:
- knowledge.go applyKnowledgeListFilter 文档列表关键词过滤
(agent 工具 list_documents、mcp-server tools_retrieve 复用)
- knowledge.go SearchKnowledge
- knowledge.go SearchKnowledgeInScopes(GET /api/v1/knowledge/search)
- tag.go ListByKB 标签搜索(count 与 data 两条查询)
- tenant.go SearchTenants 租户搜索(带/不带 tenantID 两个分支)
- tenant_member.go CountFilteredByTenant / ListPagedByTenant 成员邮箱、用户名搜索
- session.go QueryPaged 会话列表/侧栏标题搜索(LOWER LIKE 与 Postgres ILIKE 分支)
- chunk.go ListPagedChunksByKnowledgeID 分块/FAQ 搜索
chunk.go 属反向错误:关键词完全没有转义,% 和 _ 被当作通配符导致多匹配。这里同样改为
escapeLikeKeyword + ESCAPE,而不是把别处的转义去掉——关键词里的 % 和 _ 是用户想按字面
匹配的字符(文档名 IMG_2534、进度 100% 都很常见),去掉转义会让它们又变成通配符、匹配
到无关结果;只有显式 ESCAPE 才能让 Postgres 与 SQLite 行为一致。
顺带把 escapeLikePattern 收敛为 escapeLikeKeyword 的薄封装(wiki_page.go 一处),
两者原本是逐字符等价的重复实现,调用点语义不变。转义字符常量仍复用 likeEscapeChar,
未新增常量。
新增 SQLite 回归测试 internal/application/repository/like_escape_sqlite_test.go,覆盖上述
全部站点:每个用例同时埋入"字面命中行"和"通配符诱饵行",缺 ESCAPE 会因 0 行失败,缺
转义会因多匹配失败。已逐站点反向验证:去掉 ESCAPE(或去掉 chunk.go 的转义)后测试确实
失败,随后逐字节还原。
注:organization.go ListSearchable 与 user.go SearchUsers 的关键词同样未转义,但它们是
Postgres 专用路径(ILIKE / ::text),属另一类问题,不在本次改动范围内。
2026-09-29 01:31:37 +08:00
linus-liu-web
436d02fdf3
fix(compaction): 流因取消而关闭时不得当成空摘要成功返回
...
streamSummary 的 select 里 ctx.Done() 分支与 stream 关闭分支会同时就绪,
select 在就绪分支之间随机选择:已经取消的调用有一半概率走关闭分支返回 nil,
被报成"成功返回空摘要",另一半才返回 context.Canceled。CI 上因此偶发:
--- FAIL: TestSummarizationIsNotRetriedOnceTheTurnIsCancelled (0.00s)
stream_test.go:122: Error: Should be true
FAIL github.com/Tencent/WeKnora/internal/agent/compaction
这不只是测试问题。流因取消而关闭被当成成功,会让调用方把中途被截断的摘要
当有效 checkpoint 落盘(成功路径会走到 saveContextCheckpoint),而
validateSummary 只拦得住空摘要和 finish_reason 为 length 的截断。
修复:在流关闭分支返回成功之前先查 ctx.Err()。既纠正语义(取消就是取消,
不是空摘要),也消除两个分支同时就绪时的随机性。streamErr 的优先级仍在
ctx.Err() 之前,因为供应商报的错更具体;ctx 未取消、流自然关闭的正常完成
仍返回内容加 nil,stall 与重试逻辑未动。
回归用例 TestSummarizationIsCancelledWhenTheStreamCloses:假模型同步返回
一个已经关闭的 channel,传入已取消的 ctx,两个分支必然同时就绪。修复前
-count=50 有 20 次 FAIL,修复后 -count=50 全 PASS;既有 flaky 用例
TestSummarizationIsNotRetriedOnceTheTurnIsCancelled -count=100 全 PASS。
2026-09-29 01:30:01 +08:00
Victor Maznyuk
cf079b8dcd
fix(models): keep Retry-After on HTTPError and honour it in agent LLM retries
...
Endpoint.Do turns a non-2xx reply into &HTTPError{StatusCode, Body} and
drops the response headers. A caller that retries a 429 or 503 therefore
cannot see the provider's Retry-After and falls back to its own guess: the
agent retry loop waits 1s, 2s, 3s, which against a provider asking for, say,
20s spends every attempt inside the rate-limit window and then fails the
turn.
- HTTPError carries the reply's Header, and RetryAfter() parses the header
in both forms (delay-seconds and HTTP-date); absent, malformed or past
values give zero.
- The agent retry loop waits max(linear backoff, Retry-After), with the
vendor's value capped at 30s so a large Retry-After cannot hold a turn
indefinitely.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-29 01:22:15 +08:00
yeliheng-010
15d4845521
fix(rss): 修复全文回退后增量同步不重试
2026-09-29 00:53:27 +08:00
yeliheng-010
b9be7d0d0d
fix(notion): 修复页面清空后旧正文残留
2026-09-29 00:52:07 +08:00
linus-liu-web
a282d1091e
fix(feishu): 云盘分页补上 #3645 给 wiki 加的重复 page token 防护 ( #3770 )
...
ListDriveFilesAllPages 只以 next_page_token 是否为空作为终止条件,既不看
has_more,也没有重复 token 检测;同一文件里同一厂商的 ListWikiSpaces /
ListWikiNodes 已在 #3645 修过,云盘这两条防护都漏了。
厂商返回 has_more=false 但残留非空 token,或返回重复的 page_token 时,循环会
拿同一个 token 反复请求同一页:定时同步任务会在 asynq 的 2h 超时前一直打 API
(scheduler 侧 MaxRetry 5),资源选择器
GET /api/v1/datasources/:id/resources 永不返回,同时 all 每轮 append 不断增长。
按 #3645 的既有写法原样修复:listDriveFiles 透出 has_more,循环改为
if !hasMore || next == "" 才退出,并用 seenPageTokens 记录已用过的 token,重复即
返回 "feishu drive file pagination repeated page token" 错误。正常多页语义不变
(仍返回完整列表),只是不再空转。
测试:TestClientDriveListFilesPagination(drive 包)用 httptest 覆盖重复 token、
has_more=false 带残留 token、正常两页三种情况;注释掉守卫后该用例在 2s 内发出
4 万+ 次请求并以 context deadline exceeded 失败。
Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-09-29 00:51:19 +08:00
yeliheng-010
72e105f46a
fix(gitlab): 按提交快照比较增量同步变更
2026-09-29 00:50:05 +08:00
linus-liu-web
7d1d71e50d
fix(datasource/dingtalk): 块级渲染不再静默丢内容(列表按线上真实形状渲染 + 未建模块类型可见) ( #3822 )
...
* fix(datasource/dingtalk): 块级渲染不再静默丢内容(列表按契约渲染 + 未建模块类型可见)
渲染器有三处会无声地丢正文:
- 列表块只在 inline 子节点渲染结果为空时才递归子块,于是 children 里既有
inline 又有块级元素时,块级子节点的文本永远不渲染 —— 而且连 unknown 标记
都不设,完全无痕;块级列表项还会被 strings.Fields 折叠进同一个 bullet 行;
- 未建模的块类型(code / attachment / slot / sheet / unknown …)payload 解析
不出来,正文整块丢失,只剩类型名写进文档 metadata,全仓没有一行日志;
- 未建模的 inline 元素类型(slot 等,官方文档里文本放在 children)在默认分支
只写 text 字段,children 里的正文直接消失。
改动:
- 列表按官方契约渲染:一个列表块 = 一个列表项,缩进用 list.level(0-based),
同一列表的多项是共享 listId 的兄弟块(扁平模型),不假设结构嵌套;契约外的
块级子节点仍然逐个渲染,作为防御,不再二选一、不再塌行;
- 未建模的 inline 元素在自身没有文本时渲染 children,避免整段消失;
- 未建模块类型在 Fetch 路径上显式暴露(这一层同时拿得到 ctx 与节点身份):
collectUnknownBlockTypes 产出可测值,同时喂给 logger.Warnf 与
common.PipelineWarn;文档 metadata 保持不变。
code / attachment / sheet / slot 的正文渲染不在本次范围:它们的块级 JSON 形状
仍无可靠证据(官方与公开 CLI 参考的键名互相冲突),先靠告警把真实 payload
找出来再按形状补,免得用猜测的字段把"可见的丢失"变回"静默的丢失"。
* fix(datasource/dingtalk): 按实测形状补 code / attachment / unknown 三类块的渲染
只读探针在真实 adoc 文档上取到的形状(不再依赖公开参考里互相冲突的键名):
- code: {"syntax":"bash","text":"...","title":"..."},title 有时缺;语言键是
syntax 而不是 language;
- attachment: {"name":..,"size":..,"type":..,"viewType":..,"resourceId":..},
resourceId 有时缺,payload 里没有任何下载 URL;
- unknown: {"rawType":"..."},只有真实类型名,没有正文;
- table.cells 的读取路径与实测一致,未改动。
改动:
- code 渲染成围栏代码块:语言取 syntax(含反引号或换行这类无法作为 info string
的值时省略),围栏长度取 max(3, 正文最长反引号串+1),避免正文自带的围栏把代码块
提前截断;title 非空时在围栏前输出一行加粗标题;text 为空不输出空围栏,仍按未建模
类型记录并告警;
- attachment 渲染成一行纯文本 Attachment: <name> (<size>):名称做 Markdown 转义,
size 按 1024 进制保留一位小数(B/KB/MB/GB),size<=0 时省略括号;payload 没有可
解析的下载地址,因此不拿 resourceId 拼任何链接;名称为空不输出,仍按未建模类型
记录并告警;
- unknown:default 分支在 rawType 非空时把标记写成 "unknown:"+rawType,使
unknown_block_types metadata 与 warnUnknownBlockTypes 的日志/pipeline 事件直接
带真实类型名,而不是无信息量的 "unknown"(字段名、签名与调用位置均未动),
children 仍逐层递归。
既有普通块(段落/标题/引用/表格/列表)的输出逐字节不变,回归用例
TestRenderDocumentKeepsOrdinaryBlocksStable 未修改即通过。原先拿 code/attachment
当“未建模”夹具的两个用例改用空载荷的同类块与带 rawType 的 unknown 块,覆盖新的
“渲染不出内容仍要告警”语义。
* fix(datasource/dingtalk): 列表按线上真实形状渲染(块自带 text)
线上 Blocks API 返回的是一个列表项一个块,正文在块自带的 text 字段里,
没有 children、没有 list.level、也没有 listId。列表是唯一一类没有回退到
「块自带 text」的正文块 —— paragraph / heading / blockquote 都有
renderInlines(children) 取不到就取自身 text 的回退,列表直接进
renderListBlock,而那个函数只遍历 children,于是列表正文被整条丢弃;
又因为 blockType 是已知类型,switch 命中了它,连 unknown_block_types
都不会记一笔。
同一形状问题还影响 unknown:sdt 块(文档目录)的正文就在 unknown.text 里,
此前只写标记不渲染正文。
夹具取自线上 payload(markdown_live_shape_test.go),不按转述的契约自造。
---------
Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-09-29 00:48:20 +08:00
linus-liu-web
08f7e702cf
fix(datasource/dingtalk): 跳过不再静默,展开叶子不再报错
...
同步过去只保留能读的内容:没有 ingest 路径的节点被直接丢掉,日志里
一个字都没有,一个 19 个文件的库只同步出 14 个也无从得知。现在
- scanWorkspace 把「看到了但读不了」的节点一并以 skipped 返回,
sync 逐个打印身份与原因(视频/媒体是刻意不下载,原生类型是还没实现),
每个 scope 再补一行 total/synced/skipped/failed 汇总,partial sync
再也装不成一次干净的运行;
- 可重试的失败仍按失败计(不计入 skipped),并显式记一条 warn,
与确定性跳过区分开;
- 资源选择器展开一个其实没有子节点的条目(document)时返回空列表而不是
ErrResourceNotFound:叶子本来就没有子节点,而前端把 error 渲染成
展开失败的气泡,会让一次同步完全正常的操作看起来出错。前端
DataSourceEditorDialog 收到空列表后会把该行 has_children 置 false 并
保留,因此第二次展开不会再发一次空请求(该逻辑已在上游 main 中)。
跳过只在日志里报告:FetchedItem 没有 skip 字段,也不打算为它新增。
2026-09-29 00:47:02 +08:00
Fei.Chen
ec0ca46334
fix(server): run ResourceCleaner on signal shutdown instead of racing Fatalf exit ( #3804 )
...
* fix(server): signal shutdown raced Fatalf exit before ResourceCleaner ran
The signal goroutine closed the listener before calling server.Shutdown,
so Serve returned the raw accept error ('use of closed network connection')
instead of ErrServerClosed. The invoke error path then hit logger.Fatalf
(os.Exit(1)) in the same millisecond, killing the process before the
shutdown goroutine reached resourceCleaner.Cleanup. Every registered
cleaner — BrowserSkill daemon, sandbox reapers, IMService, AntsPool,
Langfuse — was skipped on every SIGTERM/SIGINT, leaking the shared bsk
daemon process and its temp home on each restart.
Two changes:
- Drop the manual listener.Close(): Shutdown closes all listeners as its
first step, releasing the port just as fast without racing Serve.
- Give resourceCleaner.Cleanup its own fresh timeout context so a slow
connection drain cannot leave Cleanup with an already-expired context,
which made it skip every entry without running any.
* fix(server): keep signal cleanup inside one grace period
Desktop quit still closed the listener before Shutdown and returned
before ResourceCleaner finished, so Fatalf could skip every hook.
Share ShutdownTimeout between drain and cleanup, run BrowserSkill
first, and do not drop later hooks when the deadline expires.
* fix(server): satisfy errcheck and line-length lint
---------
Co-authored-by: vicfei <vicfei@users.noreply.github.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-28 23:37:36 +08:00
wizardchen
c819abd958
fix(wiki): bound outstanding follow-up tasks
2026-09-28 22:02:07 +08:00
Duke
4ba85e2edf
fix(wiki): fan out follow-up triggers so backlogs drain at ingest_max_inflight
...
Since Phase 3 the consumption side (disjoint claiming, per-slug locks,
the inflight cap) fully supports concurrent batches, but nothing created
more than one trigger per completed batch: once uploads stopped, a KB
with a standing backlog drained at 1 batch x batch-size per cycle
regardless of ingest_max_inflight, leaving the wiki pool and the model
server idle.
followUpTriggerCount now re-arms min(batches the remaining rows still
need, slots that could be free when the triggers fire). The caller's
own slot releases right after scheduleFollowUp returns, hence the +1.
activeInflightSlots is a read-mostly Lua companion to the reserve
script (purge expired, then ZCARD); -1 means unknown (no Redis / Redis
error) and collapses to a single follow-up, as do maxInflight <= 1 and
Lite mode (liteLocks serialize per KB anyway). Fan-out is deliberately
skipped on a rate-limited exit so a 429 storm is not amplified.
Over-issued triggers are harmless: the ones that cannot get a slot are
acked and coalesced by scheduleCappedRetry's fixed TaskID. The slot
count renders as "unknown" in the log when it was not consulted.
2026-09-28 22:02:07 +08:00
Victor Maznyuk
bad7afa6ae
fix(sandbox): pass desktop slot timing to the renew goroutine
...
renewDesktopSlot read desktopSlotRenew and desktopSlotLease from its own
goroutine. release() stops that goroutine without waiting for it, so the
read is unordered with the test cleanup that restores the values, and
`go test -race ./internal/handler/session/` fails in
TestDesktopSlotCancelsHoldWhenKeyExpires on every run.
acquireDesktopSlot now reads both durations before starting the goroutine
and passes them in; the go statement orders the reads, and the renew loop
no longer touches the package variables. Behaviour is unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 22:01:39 +08:00
Perfecto
675b06addc
test: consolidate table summary regressions
2026-09-28 21:24:02 +08:00
Perfecto
d270a844ac
fix: reject empty table-summary model responses
2026-09-28 21:24:02 +08:00
Perfecto
d528d1fc3c
fix: skip table-summary tasks for missing documents
2026-09-28 21:22:45 +08:00
bigdu332
bdad5eea2b
fix(chat): clear stale KB scope on session restore
2026-09-28 21:20:12 +08:00