alibaba/open-code-review · error

all %d file scan(s) failed — check your LLM configuration an

Error message

all %d file scan(s) failed — check your LLM configuration and API key

What it means

dispatchSubtasks in the scan Agent fans out per-file scan subtasks and counts failures in a.subtaskFailed. When every dispatched file scan failed (failed == dispatched > 0), it aborts with this error instead of returning partial comments, since no file could be scanned. It points at LLM configuration because the dominant cause is every subtask failing auth/model setup.

Source

Thrown at internal/scan/agent.go:573

		// CommentWorkerPool.Await is cumulative across batches - that is fine
		// since batches are sequential here.
		if a.args.CommentWorkerPool != nil {
			a.args.CommentWorkerPool.Await()
		}

		dedupCheckpoints := a.maybeRunDedup(ctx, bi, batchStart)
		a.recordBatchCheckpoints(checkpoints, batchStart, dedupCheckpoints)

		// The per-file budget gate inside dispatchBatch tripped — stop
		// scheduling any remaining batches.
		if budgetHit {
			break
		}
	}

	failed := atomic.LoadInt64(&a.subtaskFailed)
	if failed > 0 && failed == dispatched {
		return nil, fmt.Errorf("all %d file scan(s) failed — check your LLM configuration and API key", dispatched)
	}
	return a.args.CommentCollector.Comments(), nil
}

type batchCheckpoint struct {
	item             model.ScanItem
	reused           bool
	originalComments []model.LlmComment
}

// recordBatchCheckpoints persists safe per-file comments after batch dedup.
// New same-file groups use the canonical result. Reused items keep their source
// checkpoint, and cross-file groups keep raw per-file comments so invalidating
// one file cannot erase another file's finding on resume.
func (a *Agent) recordBatchCheckpoints(
	checkpoints []batchCheckpoint,
	batchStart int,
	dedupCheckpoints map[string][]model.LlmComment,

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. Verify the LLM API key is set and valid (run a trivial LLM call or check env var/config file).
  2. Confirm the configured model name and base URL exist and are enabled for your account.
  3. Check network/proxy reachability to the LLM endpoint (curl the endpoint).
  4. Re-run the scan with fewer files or check per-subtask logs to find the underlying error each subtask reported.

Example fix

// before: key not exported
ocr scan ./...
// after
export LLM_API_KEY=sk-...
ocr scan ./...
Defensive patterns

Strategy: try-catch

Validate before calling

if os.Getenv("LLM_API_KEY") == "" {
    return fmt.Errorf("LLM_API_KEY is not set; scan would fail for all files")
}
// optionally: probe with a tiny completion before dispatching subtasks

Type guard

func allSubtasksFailed(failed, dispatched int64) bool {
    return dispatched > 0 && failed == dispatched
}

Try / catch

comments, err := agent.Run(ctx)
if err != nil {
    var cfgErr *ConfigError
    if errors.As(err, &cfgErr) || strings.Contains(err.Error(), "all") && strings.Contains(err.Error(), "scan(s) failed") {
        // stop; fix LLM config first — retrying won't help
        return fmt.Errorf("fix LLM configuration: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Agent.Run dispatched one or more file-scan subtasks and every single one returned an error (e.g. each subtask's LLM call failed with 401/404/network error), so atomic.LoadInt64(&a.subtaskFailed) equals the dispatched count.

Common situations: Invalid or missing API key, wrong base URL or model name in config, quota exhaustion, network/proxy outage, or all target files failing to read/scan due to encoding or permission problems.

Related errors


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