{"record":{"id":"0325c6bfe76b9c48","repo":"alibaba/open-code-review","slug":"memory-compression-task-w","errorCode":null,"errorMessage":"MEMORY_COMPRESSION_TASK: %w","messagePattern":"MEMORY_COMPRESSION_TASK: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/template/template.go","lineNumber":243,"sourceCode":"\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}\n\n// LoadScanDefault parses the embedded scan_template.json.\nfunc LoadScanDefault() (*ScanTemplate, error) {\n\tvar tpl ScanTemplate\n\tif err := json.Unmarshal(defaultScanTemplate, &tpl); err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshal default scan template: %w\", err)","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/config/template/template.go#L225-L261","documentation":"Identical to the MAIN_TASK failure but for the MEMORY_COMPRESSION_TASK: resolveConversation could not read one of that conversation's prompt files from the embedded FS, and LoadDefault wraps the cause as 'MEMORY_COMPRESSION_TASK: ...'. The library throws it because a preset template whose memory-compression prompts are missing cannot be safely used for long-session compression.","triggerScenarios":"Calling LoadDefault() when a message in MEMORY_COMPRESSION_TASK of task_template.json references a prompts/<file> that is not present in the embedded FS.","commonSituations":"Deleting or renaming the memory-compression prompt markdown while task_template.json still points at it; embed directive updated to only include a subset of prompts; typo in the PromptFile field after a refactor.","solutions":["Locate the MEMORY_COMPRESSION_TASK entry in task_template.json and fix the PromptFile path named in the error","Ensure the referenced file exists under prompts/ and is matched by the //go:embed pattern","Restore the deleted/renamed prompt file or update the manifest reference, then rebuild","Run the package's template tests (TestLoadDefault_*) which fail fast on missing prompt references"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var m map[string]any\n_ = json.Unmarshal(taskTemplateBytes, &m)\nmc, _ := m[\"MEMORY_COMPRESSION_TASK\"].(map[string]any)\nfor _, msg := range mc[\"messages\"].([]any) {\n\tpf, _ := msg.(map[string]any)[\"promptFile\"].(string)\n\tif _, err := template.TaskTemplateFS.ReadFile(pf); err != nil {\n\t\tlog.Fatalf(\"MEMORY_COMPRESSION_TASK prompt missing: %s\", pf)\n\t}\n}","typeGuard":null,"tryCatchPattern":"tpl, err := template.LoadDefault()\nif err != nil {\n\tif strings.Contains(err.Error(), \"MEMORY_COMPRESSION_TASK:\") {\n\t\treturn fmt.Errorf(\"memory compression prompt missing from embedded assets: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Include every prompt directory in //go:embed (prompts/* not prompts/*.md only if subdirs exist)","Add a manifest-vs-filesystem consistency test in CI","Grep the manifest for promptFile entries before deleting any prompt file"],"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"}