Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
test(util): pin exact field-name matching when picking a candidate
askalffe8384839cc0
diff --git a/runtime/krillinai/pkg/util/json_extract_boundary_test.go b/runtime/krillinai/pkg/util/json_extract_boundary_test.goindex 97fdb157..594d7fc0 100644--- a/runtime/krillinai/pkg/util/json_extract_boundary_test.go+++ b/runtime/krillinai/pkg/util/json_extract_boundary_test.go@@ -115,6 +115,8 @@ func TestExtractJSONObjectSkipsDecoyValues(t *testing.T) {// 函数不做猜测,修复前后都原样返回去除首尾空白的输入,调用方因此仍能拿到真实的解析错误。// 与表驱动用例中的 "[}" 互为反向:这里覆盖相反的括号顺序、字符串未闭合// (结尾是孤立反斜杠),以及所有候选都不含目标字段这几条不同的代码路径。+// 其中"大小写不一致"一条固定了取候选时按字段名精确匹配:encoding/json 解码字段是+// 不区分大小写的,这里更严格,命不中就退回原样返回,由调用方按原有逻辑报错重试。func TestExtractJSONObjectLeavesUnparsableInputAlone(t *testing.T) {tests := []struct {name string@@ -152,6 +154,12 @@ func TestExtractJSONObjectLeavesUnparsableInputAlone(t *testing.T) {key: "align",want: `{"data":{"align":[{"origin_part":"a"}]}}`,},+ {+ name: "字段名大小写不一致时不算命中",+ response: `{"Align":[{"origin_part":"a"}]}`,+ key: "align",+ want: `{"Align":[{"origin_part":"a"}]}`,+ },}for _, tt := range tests {