{"record":{"id":"c2bea4f7315866ac","repo":"alibaba/open-code-review","slug":"read-embedded-task-template-json-w","errorCode":null,"errorMessage":"read embedded task_template.json: %w","messagePattern":"read embedded task_template\\.json: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/config/template/template.go","lineNumber":219,"sourceCode":"\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\n}\n\n// LoadDefault parses the embedded task_template.json and resolves prompt file references.\nfunc LoadDefault() (*Template, error) {\n\tdata, err := templateFS.ReadFile(\"task_template.json\")\n\tif err != nil {\n\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)","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/config/template/template.go#L201-L237","documentation":"LoadDefault reads task_template.json from the embedded filesystem (go:embed). If the file is missing from the embedded FS or cannot be read (e.g. the embed directive excludes it, or the binary was built from a broken tree), the read error is wrapped with this message and returned. It is a build/packaging defect, not a runtime config problem: end users cannot fix it by editing files because the content is compiled into the binary.","triggerScenarios":"Calling LoadDefault() when task_template.json is not present in the embedded templateFS — typically the //go:embed pattern does not include the file, the file was renamed/deleted before go build, or templateFS points at a wrong root so ReadFile(\"task_template.json\") fails.","commonSituations":"Developers adding a new template file but forgetting to update the embed pattern; building with an outdated copy of the repo; CI builds where the JSON was removed or moved; accidentally shadowing the embed directory during code generation.","solutions":["Check the //go:embed directive in the package covers task_template.json (e.g. embed task_template.json prompts/*) and that the file exists at that path relative to template.go","Run go build ./... from a clean checkout to confirm the embed succeeds; fix any 'pattern ... no matching files' build error","Verify the file name casing exactly matches task_template.json (embed paths are case-sensitive, even on macOS/Windows)","If loading fails at runtime, rebuild and redeploy the binary — the embedded FS cannot be patched on disk"],"exampleFix":"// before (template.go)\n//go:embed prompts/*.md\nvar templateFS embed.FS\n// after\n//go:embed task_template.json prompts/*.md\nvar templateFS embed.FS","handlingStrategy":"try-catch","validationCode":"// Go has no pre-call check for an embed FS beyond building; verify the asset at startup\ndata, err := template.TaskTemplateFS.ReadFile(\"task_template.json\")\nif err != nil { log.Fatalf(\"embedded template missing (rebuild binary): %v\", err) }","typeGuard":null,"tryCatchPattern":"tpl, err := template.LoadDefault()\nif err != nil {\n\tif errors.Is(err, fs.ErrNotExist) {\n\t\tlog.Fatalf(\"embedded task_template.json missing — rebuild the binary from a complete checkout: %v\", err)\n\t}\n\treturn fmt.Errorf(\"loading default template: %w\", err)\n}","preventionTips":["Keep task_template.json matched by the //go:embed directive and add a build test that loads it","Add TestLoadDefault to CI so a missing embed fails the build, not production","Never rename embedded assets without grepping the embed patterns"],"tags":["go","embed","filesystem"],"backgroundTag":"embedded-asset-missing","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}