alibaba/open-code-review · error

%s: %w

Error message

%s: %w

What it means

resolveOptionalConversation wraps errors from resolveConversation with the logical conversation name, producing a two-layer message like `default: read prompt file "x": ...`. It exists so LoadDefault can report which named conversation (e.g. default/review) failed, not just the raw file error.

Source

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

		data, err := templateFS.ReadFile("prompts/" + mm.PromptFile)
		if err != nil {
			return LlmConversation{}, fmt.Errorf("read prompt file %q: %w", mm.PromptFile, err)
		}
		conv.Messages[i] = ChatMessage{
			Role:    mm.Role,
			Content: strings.TrimRight(string(data), "\r\n"),
		}
	}
	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

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. Look at the inner `read prompt file %q` message to find the actual missing file
  2. Fix the PromptFile reference in task_template.json or add the file under prompts/ with go:embed coverage
  3. Rebuild so the embedded template bundle matches the manifest
  4. Restore the pristine task_template.json if it was hand-modified

Example fix

// before
"conversation": { "name": "default", "promptFile": "old_name.md" }
// after
"conversation": { "name": "default", "promptFile": "review_system.md" }
Defensive patterns

Strategy: try-catch

Try / catch

tpl, err := template.LoadDefault()
if err != nil {
    var name, inner string
    // message shape: "<conversation>: read prompt file %q: ..."
    if parts := strings.SplitN(err.Error(), ": read prompt file ", 2); len(parts) == 2 {
        fmt.Fprintf(os.Stderr, "conversation %q failed: %s\n", parts[0], parts[1])
    }
    return err
}

Prevention

When it happens

Trigger: LoadDefault passes a non-nil manifestConversation to resolveOptionalConversation and the inner resolveConversation fails (typically a missing prompts/ file, i.e. error 218), producing this wrapper.

Common situations: Same as error 218 — a manifest entry whose prompt file is missing from the embedded FS — but surfaced with the conversation name prefix, e.g. from a customized template manifest in a patched build.

Related errors


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