Closed
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Motivation
loadConfig在写回(env writeback)模式下的早退问题:当环境变量DS2API_CONFIG_JSON/CONFIG_JSON存在但解析失败时,应回退到磁盘上的持久化配置以维持 file-backed 行为,避免重启后丢失 keys/accounts。CONTENT_FILTER的文本无差别截断,只有确认为上游泄漏签名时才裁剪,以免破坏正常可见内容(例如对审查机制的说明)。Description
loadConfig中,当DS2API_CONFIG_JSON/CONFIG_JSON无法解析时增加逻辑:若非 Vercel 且允许写回,则尝试读取ConfigPath()指向的持久化文件并在可解析时返回该文件配置(并将fromEnv=false)。internal/sse/content_filter_leak.go中收紧裁剪逻辑:搜索到CONTENT_FILTER后仅在其后缀匹配已知泄漏签名(例如中文“你好,这个问题我暂时无法回答”之类前缀)时才从文本中去除该后缀,否则保留原文。TestEnvBackedStoreWritebackFallsBackToPersistedFileWhenEnvMalformed覆盖 env JSON 畸形但磁盘配置可用的回退场景,以及TestParseDeepSeekContentLineKeepsLegitContentFilterMentions验证合法提及CONTENT_FILTER不被误截断。internal/config/store.go、internal/config/config_test.go、internal/sse/content_filter_leak.go、internal/sse/line_test.go。Testing
go test ./internal/config ./internal/sse,两组测试均通过。TestEnvBackedStoreWritebackFallsBackToPersistedFileWhenEnvMalformed和TestParseDeepSeekContentLineKeepsLegitContentFilterMentions已在本地测试套件中通过。Codex Task