{"record":{"id":"8a18c18dac21631e","repo":"alibaba/open-code-review","slug":"unmarshal-test-task-config-w","errorCode":null,"errorMessage":"unmarshal test task config: %w","messagePattern":"unmarshal test task config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/testconnection/testconnection.go","lineNumber":37,"sourceCode":"type LlmConversation struct {\n\tTimeout  int           `json:\"timeout\"`\n\tMessages []ChatMessage `json:\"messages\"`\n}\n\n// ChatMessage represents a single message in a conversation.\ntype ChatMessage struct {\n\tRole    string `json:\"role\"`\n\tContent string `json:\"content\"`\n}\n\n//go:embed task.json\nvar defaultTask []byte\n\n// LoadDefault parses the embedded task.json and returns the TEST_TASK conversation.\nfunc LoadDefault() (*LlmConversation, error) {\n\tvar tasks TestTask\n\tif err := json.Unmarshal(defaultTask, &tasks); err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshal test task config: %w\", err)\n\t}\n\treturn &tasks.TestTask, nil\n}\n\nfunc resolveLang(lang string) string {\n\tif lang == \"\" {\n\t\treturn \"English\"\n\t}\n\treturn lang\n}\n\n// ApplyLanguage injects a language directive into all system-role messages of this conversation.\nfunc (c *LlmConversation) ApplyLanguage(lang string) {\n\tinstruction := \"\\n\\nAlways respond in \" + resolveLang(lang) + \".\"\n\tfor i := range c.Messages {\n\t\tif c.Messages[i].Role == \"system\" {\n\t\t\tc.Messages[i].Content += instruction\n\t\t}","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/config/testconnection/testconnection.go#L19-L55","documentation":"LoadDefault unmarshals the embedded testconnection task.json into a TestTask struct; this error wraps any JSON decode failure. Since the JSON is embedded at build time, this error almost always indicates a corrupted build artifact or a struct/JSON schema mismatch introduced by editing task.json or the Go types.","triggerScenarios":"json.Unmarshal failing on the embedded defaultTask bytes inside LoadDefault(), called by runLLMTest (the test-connection CLI command).","commonSituations":"A developer edited embedded task.json and broke its JSON syntax or changed field types; struct tags in TestTask no longer match the JSON schema; a corrupted binary or a build system replacing the embedded asset.","solutions":["Validate the embedded internal/config/testconnection/task.json with a JSON linter and fix syntax/type errors","Align the TestTask struct fields/tags with the actual JSON schema","Rebuild the binary cleanly to refresh the embedded asset","Run the test connection command with the wrapped inner error (%w) visible to identify the exact JSON offset"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var probe json.RawMessage = defaultTask; var chk map[string]any; _ = json.Unmarshal(probe, &chk) // fails fast if embedded asset is corrupt","typeGuard":null,"tryCatchPattern":"conv, err := testconnection.LoadDefault()\nif err != nil {\n    var unmarshalErr *json.UnmarshalTypeError\n    if errors.As(err, &unmarshalErr) { /* schema mismatch: field %s */ }\n    return fmt.Errorf(\"test-connection unavailable: %w\", err)\n}","preventionTips":["Validate task.json in CI before it is embedded","Keep TestTask struct tags in sync with the JSON schema","Rebuild after modifying embedded assets"],"tags":["json","embedded-config","unmarshal"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}