{"record":{"id":"cec7d78cc924695b","repo":"alibaba/open-code-review","slug":"read-prompt-file-q-w","errorCode":null,"errorMessage":"read prompt file %q: %w","messagePattern":"read prompt file %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/template/template.go","lineNumber":194,"sourceCode":"\tMaxCompletionTokens         int                   `json:\"MAX_COMPLETION_TOKENS\"`\n\tMaxToolRequestTimes         int                   `json:\"MAX_TOOL_REQUEST_TIMES\"`\n\tPlanModeLineThreshold       int                   `json:\"PLAN_MODE_LINE_THRESHOLD\"`\n\tPlanModeGroupLineThreshold  int                   `json:\"PLAN_MODE_GROUP_LINE_THRESHOLD\"`\n\tGroupingMinFiles            int                   `json:\"GROUPING_MIN_FILES\"`\n\tGroupingBundleLineThreshold int                   `json:\"GROUPING_BUNDLE_LINE_THRESHOLD\"`\n\tMaxReviewRounds             int                   `json:\"MAX_REVIEW_ROUNDS\"`\n\tReLocationTask              *manifestConversation `json:\"RE_LOCATION_TASK,omitempty\"`\n\tReviewFilterTask            *manifestConversation `json:\"REVIEW_FILTER_TASK,omitempty\"`\n\tGroupingTask                *manifestConversation `json:\"GROUPING_TASK,omitempty\"`\n}\n\nfunc resolveConversation(m manifestConversation) (LlmConversation, error) {\n\tvar conv LlmConversation\n\tconv.Messages = make([]ChatMessage, len(m.Messages))\n\tfor i, mm := range m.Messages {\n\t\tdata, err := templateFS.ReadFile(\"prompts/\" + mm.PromptFile)\n\t\tif err != nil {\n\t\t\treturn LlmConversation{}, fmt.Errorf(\"read prompt file %q: %w\", mm.PromptFile, err)\n\t\t}\n\t\tconv.Messages[i] = ChatMessage{\n\t\t\tRole:    mm.Role,\n\t\t\tContent: strings.TrimRight(string(data), \"\\r\\n\"),\n\t\t}\n\t}\n\treturn conv, nil\n}\n\nfunc resolveOptionalConversation(m *manifestConversation, name string) (*LlmConversation, error) {\n\tif m == nil {\n\t\treturn nil, nil\n\t}\n\tconv, err := resolveConversation(*m)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", name, err)\n\t}\n\treturn &conv, nil","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/config/template/template.go#L176-L212","documentation":"resolveConversation materializes a template conversation from the embedded FS (embed.FS `prompts/` directory). When a manifest entry references a PromptFile that does not exist in the embedded template bundle, the embed.FS ReadFile error is wrapped with the file name. This indicates the shipped template manifest and its prompt files are out of sync — normally a build/packaging bug, not user input.","triggerScenarios":"LoadDefault -> resolveOptionalConversation -> resolveConversation processes a manifestConversation whose mm.PromptFile (e.g. \"review_system.md\") is absent under prompts/ in the embedded templateFS.","commonSituations":"A custom or patched build where task_template.json was edited to reference a new prompt file that was never added to the embedded prompts/ directory; an incomplete `go build` after deleting prompt files; go:embed pattern excluding the file so embed.FS lacks it.","solutions":["Verify the referenced file exists in internal/config/template/prompts/ and that the go:embed pattern includes it","If task_template.json was customized, correct the PromptFile name to match an existing prompts/ file","Rebuild cleanly (go clean && make build) so the embed FS is regenerated","Report upstream if it occurs with an official release build"],"exampleFix":"// before (task_template.json)\n\"promptFile\": \"review-system-v2.md\"   // file not embedded\n// after\n\"promptFile\": \"review_system.md\"   // matches prompts/review_system.md","handlingStrategy":"try-catch","validationCode":"// pre-flight: confirm the prompt file exists in the embedded FS\n// (test code, not user code — embed.FS is internal)\nfunc promptExists(tfs fs.FS, name string) bool {\n    _, err := fs.Stat(tfs, \"prompts/\"+name)\n    return err == nil\n}\n// verify all manifest prompt files resolve before shipping a patched template","typeGuard":null,"tryCatchPattern":"tpl, err := template.LoadDefault()\nif err != nil {\n    if strings.Contains(err.Error(), \"read prompt file\") {\n        fmt.Fprintln(os.Stderr, \"embedded template manifest references a missing prompt file; rebuild or restore task_template.json\")\n    }\n    return err\n}","preventionTips":["If customizing templates, always add new prompt files under prompts/ and keep the go:embed pattern inclusive","Add a unit test that resolves every PromptFile referenced by task_template.json","Rebuild after touching anything in internal/config/template","Do not hand-edit task_template.json in release builds"],"tags":["go","embed","template","fs"],"backgroundTag":"missing-embedded-file","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}