alibaba/open-code-review · error

load test task config: %w

Error message

load test task config: %w

What it means

This error wraps a failure from testconnection.LoadDefault, which loads the built-in default test-conversation task used by `ocr llm test`. This is an internal fixture/config load, so failure usually means the embedded task resource is unavailable or an on-disk override of the test task is unreadable or malformed.

Source

Thrown at cmd/opencodereview/llm_cmd.go:71

func runLLMTest() error {
	cfgPath, err := resolveConfigPath()
	if err != nil {
		return err
	}

	appCfg, err := LoadAppConfig(cfgPath)
	if err != nil {
		return fmt.Errorf("load config: %w", err)
	}

	ep, err := llm.ResolveEndpoint(cfgPath)
	if err != nil {
		return fmt.Errorf("resolve LLM endpoint: %w", err)
	}

	task, err := testconnection.LoadDefault()
	if err != nil {
		return fmt.Errorf("load test task config: %w", err)
	}
	var lang string
	if appCfg != nil {
		lang = appCfg.Language
	}
	task.ApplyLanguage(lang)

	timeout := 30 * time.Second
	if task.Timeout > 0 {
		timeout = time.Duration(task.Timeout) * time.Second
	}

	// No retry collector: llm test is a connectivity probe, not a review, and the
	// retry report only describes ocr review.
	llmClient := llm.NewLLMClient(ep, nil)

	messages := make([]llm.Message, 0, len(task.Messages))
	for _, m := range task.Messages {

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. If you overrode the test task file, fix its syntax/fields to match the expected schema.
  2. Delete or rename your custom test-task override so the built-in default loads.
  3. Reinstall/rebuild the binary to restore the embedded default task.
  4. Read the wrapped cause after 'load test task config:' for the exact parse error and line.

Example fix

// before (test task missing messages)
timeout = 30
// after
timeout = 30
[[messages]]
role = "user"
content = "Say hello."
Defensive patterns

Strategy: fallback

Validate before calling

task, err := testconnection.LoadDefault()
if err != nil {
    // fall back to a minimal built-in probe instead of failing
    task = &testconnection.Task{Timeout: 30, Messages: []testconnection.Message{{Role: "user", Content: "ping"}}}
}

Try / catch

task, err := testconnection.LoadDefault()
if err != nil {
    return fmt.Errorf("load test task config: %w", err)
}

Prevention

When it happens

Trigger: Running `ocr llm test` when testconnection.LoadDefault() returns an error — e.g. a custom test-task file overriding the default is missing fields, has invalid syntax, or the embedded default cannot be unmarshalled.

Common situations: Users who customized the test task file and introduced a schema error; packaging/bundling issues in development builds where embedded assets are absent.

Related errors


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