{"record":{"id":"e3bcd3110bb8e47f","repo":"alibaba/open-code-review","slug":"main-task-w","errorCode":null,"errorMessage":"MAIN_TASK: %w","messagePattern":"MAIN_TASK: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/template/template.go","lineNumber":237,"sourceCode":"\t\treturn nil, fmt.Errorf(\"read embedded task_template.json: %w\", err)\n\t}\n\tvar m templateManifest\n\tif err := json.Unmarshal(data, &m); err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshal task_template manifest: %w\", err)\n\t}\n\n\tvar tpl Template\n\ttpl.MaxTokens = m.MaxTokens\n\ttpl.MaxCompletionTokens = m.MaxCompletionTokens\n\ttpl.MaxToolRequestTimes = m.MaxToolRequestTimes\n\ttpl.PlanModeLineThreshold = m.PlanModeLineThreshold\n\ttpl.PlanModeGroupLineThreshold = m.PlanModeGroupLineThreshold\n\ttpl.GroupingMinFiles = m.GroupingMinFiles\n\ttpl.GroupingBundleLineThreshold = m.GroupingBundleLineThreshold\n\ttpl.MaxReviewRounds = m.MaxReviewRounds\n\n\tif tpl.MainTask, err = resolveConversation(m.MainTask); err != nil {\n\t\treturn nil, fmt.Errorf(\"MAIN_TASK: %w\", err)\n\t}\n\tif tpl.PlanTask, err = resolveOptionalConversation(m.PlanTask, \"PLAN_TASK\"); err != nil {\n\t\treturn nil, err\n\t}\n\tif tpl.MemoryCompressionTask, err = resolveConversation(m.MemoryCompressionTask); err != nil {\n\t\treturn nil, fmt.Errorf(\"MEMORY_COMPRESSION_TASK: %w\", err)\n\t}\n\tif tpl.ReLocationTask, err = resolveOptionalConversation(m.ReLocationTask, \"RE_LOCATION_TASK\"); err != nil {\n\t\treturn nil, err\n\t}\n\tif tpl.ReviewFilterTask, err = resolveOptionalConversation(m.ReviewFilterTask, \"REVIEW_FILTER_TASK\"); err != nil {\n\t\treturn nil, err\n\t}\n\tif tpl.GroupingTask, err = resolveOptionalConversation(m.GroupingTask, \"GROUPING_TASK\"); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &tpl, nil\n}","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/config/template/template.go#L219-L255","documentation":"LoadDefault resolves the MAIN_TASK conversation by reading each message's prompt file from the embedded FS via resolveConversation. If a referenced prompt file (m.MainTask.Messages[i].PromptFile) cannot be read, the error is wrapped as 'MAIN_TASK: ...'. This means the manifest's main task references a prompt file that is missing from the embedded assets.","triggerScenarios":"Calling LoadDefault() when a message in MAIN_TASK of task_template.json names a prompts/<file> that is absent from the embedded FS, or the promptFile value has a wrong path/casing relative to the embed root.","commonSituations":"Renaming a prompt markdown file without updating task_template.json; embed pattern not covering a new prompts/ subdirectory; typos in the PromptFile field; deleting a prompt as part of cleanup while the manifest still references it.","solutions":["Open task_template.json, find the MAIN_TASK message whose PromptFile is named in the wrapped error, and correct the path","Confirm the prompt file exists under the package's prompts/ directory and matches the //go:embed pattern (add subdirectories with prompts/** or explicit entries)","Check file-name casing exactly matches the manifest value","Rebuild after fixing, since both the manifest and prompts are embedded"],"exampleFix":"// before (task_template.json)\n{\"MAIN_TASK\": {\"messages\": [{\"role\": \"system\", \"promptFile\": \"prompts/main-system.md\"}]}}\n// after (after renaming file to prompts/main_task_system.md)\n{\"MAIN_TASK\": {\"messages\": [{\"role\": \"system\", \"promptFile\": \"prompts/main_task_system.md\"}]}}","handlingStrategy":"validation","validationCode":"var m map[string]any\n_ = json.Unmarshal(taskTemplateBytes, &m)\nmain, _ := m[\"MAIN_TASK\"].(map[string]any)\nfor _, msg := range main[\"messages\"].([]any) {\n\tpf, _ := msg.(map[string]any)[\"promptFile\"].(string)\n\tif _, err := template.TaskTemplateFS.ReadFile(pf); err != nil {\n\t\tlog.Fatalf(\"MAIN_TASK prompt missing: %s\", pf)\n\t}\n}","typeGuard":null,"tryCatchPattern":"tpl, err := template.LoadDefault()\nif err != nil {\n\tif strings.Contains(err.Error(), \"MAIN_TASK:\") {\n\t\treturn fmt.Errorf(\"main task prompt file missing from embedded assets — check task_template.json promptFile paths: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["When renaming prompt files, update task_template.json in the same commit","Keep //go:embed patterns broad enough (prompts/*) to cover all referenced files","Add a test iterating manifest promptFile entries and ReadFile-ing each"],"tags":["go","embed","template","missing-file"],"backgroundTag":"embedded-prompt-file-missing","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}