alibaba/open-code-review · critical

read embedded task_template.json: %w

Error message

read embedded task_template.json: %w

What it means

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.

Source

Thrown at internal/config/template/template.go:219

	return conv, nil
}

func resolveOptionalConversation(m *manifestConversation, name string) (*LlmConversation, error) {
	if m == nil {
		return nil, nil
	}
	conv, err := resolveConversation(*m)
	if err != nil {
		return nil, fmt.Errorf("%s: %w", name, err)
	}
	return &conv, nil
}

// LoadDefault parses the embedded task_template.json and resolves prompt file references.
func LoadDefault() (*Template, error) {
	data, err := templateFS.ReadFile("task_template.json")
	if err != nil {
		return nil, fmt.Errorf("read embedded task_template.json: %w", err)
	}
	var m templateManifest
	if err := json.Unmarshal(data, &m); err != nil {
		return nil, fmt.Errorf("unmarshal task_template manifest: %w", err)
	}

	var tpl Template
	tpl.MaxTokens = m.MaxTokens
	tpl.MaxCompletionTokens = m.MaxCompletionTokens
	tpl.MaxToolRequestTimes = m.MaxToolRequestTimes
	tpl.PlanModeLineThreshold = m.PlanModeLineThreshold
	tpl.PlanModeGroupLineThreshold = m.PlanModeGroupLineThreshold
	tpl.GroupingMinFiles = m.GroupingMinFiles
	tpl.GroupingBundleLineThreshold = m.GroupingBundleLineThreshold
	tpl.MaxReviewRounds = m.MaxReviewRounds

	if tpl.MainTask, err = resolveConversation(m.MainTask); err != nil {
		return nil, fmt.Errorf("MAIN_TASK: %w", err)

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. 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
  2. Run go build ./... from a clean checkout to confirm the embed succeeds; fix any 'pattern ... no matching files' build error
  3. Verify the file name casing exactly matches task_template.json (embed paths are case-sensitive, even on macOS/Windows)
  4. If loading fails at runtime, rebuild and redeploy the binary — the embedded FS cannot be patched on disk

Example fix

// before (template.go)
//go:embed prompts/*.md
var templateFS embed.FS
// after
//go:embed task_template.json prompts/*.md
var templateFS embed.FS
Defensive patterns

Strategy: try-catch

Validate before calling

// Go has no pre-call check for an embed FS beyond building; verify the asset at startup
data, err := template.TaskTemplateFS.ReadFile("task_template.json")
if err != nil { log.Fatalf("embedded template missing (rebuild binary): %v", err) }

Try / catch

tpl, err := template.LoadDefault()
if err != nil {
	if errors.Is(err, fs.ErrNotExist) {
		log.Fatalf("embedded task_template.json missing — rebuild the binary from a complete checkout: %v", err)
	}
	return fmt.Errorf("loading default template: %w", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02). Data as JSON: /api/errors/c2bea4f7315866ac. Report an issue: GitHub.