{"record":{"id":"ead02cd8f64745b6","repo":"alibaba/open-code-review","slug":"enumerate-files-w","errorCode":null,"errorMessage":"enumerate files: %w","messagePattern":"enumerate files: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/scan/agent.go","lineNumber":319,"sourceCode":"// dispatch one subtask per file → collect comments.\nfunc (a *Agent) Run(ctx context.Context) ([]model.LlmComment, error) {\n\tif len(a.args.Template.MainTask.Messages) == 0 {\n\t\treturn nil, fmt.Errorf(\"scan template MAIN_TASK is missing or empty\")\n\t}\n\n\t// Base prompt-cache affinity key for any LLM request in this run that a\n\t// task doesn't re-scope. Each task conversation (plan, per-file main\n\t// loop, dedup, summary) refines it with llm.SessionTaskKey where it\n\t// starts, so affinity keys stay per-conversation — the granularity\n\t// provider prompt caches actually reuse prefixes at.\n\tctx = llm.ContextWithSessionKey(ctx, a.SessionID())\n\n\tctx, scanSpan := telemetry.StartSpan(ctx, \"scan.enumerate\")\n\tprovider := NewProvider(a.args.RepoDir, a.args.Paths, a.args.GitRunner, a.args.MaxFileSizeBytes)\n\titems, err := provider.Enumerate(ctx)\n\tif err != nil {\n\t\tscanSpan.End()\n\t\treturn nil, fmt.Errorf(\"enumerate files: %w\", err)\n\t}\n\ttelemetry.SetAttr(scanSpan, \"files.enumerated\", len(items))\n\tscanSpan.End()\n\n\ta.items = items\n\ta.injectScanContentMap()\n\ta.args.Tools.Freeze()\n\n\ttotalDiscovered := len(a.items)\n\ta.items = a.filterScanItems(a.items)\n\ta.items = a.filterLargeScans(a.items)\n\n\treviewable := len(a.items)\n\tfmt.Fprintf(stdout.Writer(), \"[ocr] full-scan: %d file(s) discovered, reviewing %d in %s\\n\",\n\t\ttotalDiscovered, reviewable, a.args.RepoDir)\n\n\tif reviewable == 0 {\n\t\tfmt.Fprintln(stdout.Writer(), \"[ocr] No reviewable files. Skipping scan.\")","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/scan/agent.go#L301-L337","documentation":"Agent.Run wraps a failure from the file provider's Enumerate with 'enumerate files: %w'. Enumerate walks the repo paths (via git and filesystem) to produce the candidate file list; any failure there (git command failure, unreadable path, repository problems) surfaces under this prefix after the telemetry span is closed.","triggerScenarios":"provider.Enumerate(ctx) returns an error: the git runner fails (not a git repo, git binary missing, corrupt index), a supplied --paths entry does not exist or is unreadable, or filesystem traversal hits a permission error.","commonSituations":"Running ocr outside a git repository; specifying a path that was deleted or renamed; running in a CI checkout with submodules not initialized; insufficient read permissions on a target directory.","solutions":["Run from (or point --repo-dir at) a valid git working tree and confirm `git status` works there","Check each supplied path exists and is readable; fix typos or remove stale paths","Ensure the git binary is installed and on PATH in the execution environment (especially CI containers)"],"exampleFix":"// before\nocr review --paths ./src_old\n// after — path renamed\nocr review --paths ./src","handlingStrategy":"try-catch","validationCode":"// verify repo and paths before scanning\nif _, err := os.Stat(filepath.Join(repoDir, \".git\")); err != nil {\n    return fmt.Errorf(\"%s is not a git repository\", repoDir)\n}\nfor _, p := range paths {\n    if _, err := os.Stat(p); err != nil {\n        return fmt.Errorf(\"path %q does not exist\", p)\n    }\n}","typeGuard":null,"tryCatchPattern":"comments, err := agent.Run(ctx)\nif err != nil {\n    var enumErr error\n    if strings.Contains(err.Error(), \"enumerate files\") {\n        errors.As(err, &enumErr) // inspect wrapped git/fs cause; fix repo or paths\n    }\n}","preventionTips":["Run inside a valid git working tree (or pass --repo-dir pointing at one)","Verify all --paths entries exist and are readable before scanning","Ensure the git binary is available in CI images"],"tags":["filesystem","git","scan","enumeration"],"backgroundTag":"file-enumeration-failed","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}