Repository navigation
fix(backend): 旧版对话导入上限从 64 MiB 放宽到 512 MiB - #84
Merged
Merged
Conversation
LiveAgent 迁移旧对话时,请求里的 source_metadata 会把对话正文再重复两遍, 带内联图片的长对话整体超过 64 MiB,返回 413,用户看到「超出单次导入限制」。 导入是桌面端一次性迁移,上限只用来挡失控请求;512 MiB 仍低于 maxOversizedBodyDrainBytes (1 GiB),超限时客户端依然能收到可读的 413。
5 tasks done
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.
问题
LiveAgent v2 从 1.x 迁移旧对话时,单条对话通过
POST /v1/migrations/liveagent-history一次性导入。前端请求里,source_metadata会把对话正文再重复两遍(original.segments[].messagesJson和segments[].messages_json),所以带内联图片的长对话整体超过 64 MiB,K-brain 返回 413,桌面端显示「对话超过当前 K-brain 的单次导入大小限制」,这条对话无法迁移。用户已实际遇到。改动
maxLegacyHistoryBodyBytes:64 << 20改为512 << 20,并更新注释。TestOversizedJSONBodiesReturnReadable413的期望文案改为512 MiB。导入是桌面端的一次性迁移,这个上限只用来挡失控请求。512 MiB 仍低于
maxOversizedBodyDrainBytes(1 GiB),超限请求依然能收到可读的 413,不会变成连接重置。其他接口的通用 4 MiB 上限不变。验证
go vet ./internal/backendgo test ./internal/backend -count=1:通过(53s),其中包括 513 MiB 超限请求返回可读 413 的用例。LiveAgent 侧会把 K-brain 锁定到包含本改动的版本,并让之前因 413 失败的对话在启动时自动重试一次。