fix(knowledge): restore the per-base document-cap error mapping from #1013 - #1147
Draft
Lesereingrape wants to merge 1 commit into
Draft
Lesereingrape wants to merge 1 commit into
Lesereingrape wants to merge 1 commit into
Conversation
`5e34c8a0`("Apply the remaining working-tree changes")把 TencentCloud#1013 已经合并的 分类修复连同两条回归测试一起回退了:`_map_knowledge_error` 又按字面量 「at most 100」匹配文档数上限,而 `KnowledgeRepo.create_document` 拼的是 可配置的 `max_documents`,于是上限不是默认值 100 的库(2、500…)在传满文档 时收到 409 `KNOWLEDGE_BASE_LIMIT`「每个用户最多可创建 20 个知识库」。 本提交按 TencentCloud#1013 原样恢复两条措辞判断与对应测试;未改动 CHANGELOG,因为 develop 的 `## [Unreleased] / ### 修复` 第一条至今仍在宣传这条修复。 (restore of the mapping merged as 4e09aeb, reverted by 5e34c8a) Co-authored-by: sxh313 <250161920+sxh313@users.noreply.github.com>
This was referenced Oct 1, 2026
Lesereingrape
marked this pull request as draft
October 5, 2026 13:46
This branch has not been deployed
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.
What
Re-applies the error-mapping fix that was merged as #1013 (
4e09aeb9) and then dropped fromdevelopby5e34c8a0("Apply the remaining working-tree changes"). In_map_knowledge_error(src/octop/api/routers/knowledge_bases.py):"support at most"instead of the literal"at most 100";"can own at most"instead of"at most" and "knowledge bases"— the document-cap message also contains "knowledge bases", which is what made the two collide;KnowledgeRepowording so the coupling cannot rot silently again.CHANGELOG.mdis unchanged on purpose: the first bullet under## [Unreleased] / ### 修复ondevelopstill describes exactly this fix, so the changelog and the code disagree right now. That is also why I read5e34c8a0as a working-tree carry-over rather than a deliberate rollback — #1139/#1140/#1141 restore its other victims the same way.Why it matters to a user
KnowledgeRepo.create_documentraisesf"knowledge bases support at most {max_documents} documents", andmax_documentshas been configurable per base since90b8ca25(CreateBaseBody.max_documents,ge=0, le=10_000, default 100). So for any base whose cap is not exactly 100, uploading one document too many answers409 KNOWLEDGE_BASE_LIMIT— "每个用户最多可创建 20 个知识库" — to a user who is complaining about documents. Only bases at the default cap report correctly.Attribution
The fix is sxh313's (#1013); the commit keeps him as author and carries a
restore of … 4e09aeb9, reverted by 5e34c8a0note. My part was noticing the code/changelog mismatch, re-deriving the reachable path, and re-filing it with the measurement below.Verification
Against
origin/develop(2209cdc9). I cannot runmake allon this machine (nomake), so I ran the four underlying steps by hand.Red — the two restored tests against
develop's current source:(The second restored test passes on both sides — it is the guard that keeps the base cap wording mapping to
KNOWLEDGE_BASE_LIMIT, which is why the first replacement cannot be made naively.)Green — with the mapping restored:
Two disclosures:
tests/unittree for this branch. Locally on a Chinese Windows box that tree is red for unrelated environment reasons (tests/unit/db/*, cp936 migration reads) — tracked by [bug] 中文 Windows(cp936) 上跑 tests/unit/db:22 处 read_text() 按平台编码读迁移 SQL,19 个用例报 UnicodeDecodeError #1070 / test(db): 迁移脚本统一按 UTF-8 读,中文 Windows(cp936) 本地跑测试不再红 19 个 (#1070) #1072, and it is red ondevelopfor those and for the deps switch in chore(deps): switch runtime packages to octop-* 1.0.0 #1136, independently of this diff._map_knowledge_error+KnowledgeRepo.create_documentplus the unit test above; I did not drive a real upload through a running gateway.Overlap with #910
My open #910 also edits
_map_knowledge_error— but a different branch of it (addingKNOWLEDGE_PATH_INVALIDaround line 246), and both PRs append their tests at the end oftests/unit/api/test_knowledge_bases.py. If #910 lands first I will rebase this one; if this lands first, #910's remaining conflict is one hunk at the end of that test file.AI assistance
This was prepared with an AI coding agent (Qoder CLI) on my machine; the diff, the red/green measurements and this text are agent output.