{"record":{"id":"526ca5315631e6e6","repo":"alibaba/open-code-review","slug":"load-diffs-w-526ca5","errorCode":null,"errorMessage":"load diffs: %w","messagePattern":"load diffs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/identity.go","lineNumber":58,"sourceCode":"//\n// Those filter passes are chatty, and the review that follows in the same\n// command prints them again, so this stays silent. stdout.Quiet is safe here for\n// the reason it documents: this is pre-flight work on the main goroutine, before\n// any concurrent output exists.\nfunc ResolveIdentity(ctx context.Context, args Args) (*SealedInput, error) {\n\tdefer stdout.Quiet()()\n\n\tresolution, err := resolveInputBeforeDiff(ctx, args)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resolution != nil {\n\t\targs.SealedInput = resolution\n\t}\n\n\ta := &Agent{args: args}\n\tif err := a.loadDiffs(ctx); err != nil {\n\t\treturn nil, fmt.Errorf(\"load diffs: %w\", err)\n\t}\n\ta.diffs = a.filterDiffs(a.diffs)\n\ta.diffs = a.filterLargeDiffs(a.diffs)\n\treturn &SealedInput{Identity: a.runIdentity(), Resolution: a.inputResolution}, nil\n}\n\n// resolveInputBeforeDiff turns every moving head ref into an immutable commit\n// before the diff used for admission is loaded. Range mode then computes its\n// merge-base against that frozen head; commit mode needs only the frozen head.\nfunc resolveInputBeforeDiff(ctx context.Context, args Args) (*diff.InputResolution, error) {\n\tswitch {\n\tcase args.Commit != \"\":\n\t\thead, err := resolveCommitHead(ctx, args, args.Commit)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &diff.InputResolution{ResolvedHead: head}, nil\n\tcase args.From != \"\" && args.To != \"\":","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/agent/identity.go#L40-L76","documentation":"ResolveIdentity wraps any failure from Agent.loadDiffs with the 'load diffs:' prefix while computing the pre-flight identity for a review run. loadDiffs runs git to obtain the diff the review would analyze; if git fails (bad ref, missing repo, plumbing errors), the resume/admission flow aborts before any session is created. The wrapped error preserves the underlying git cause.","triggerScenarios":"Calling agent.ResolveIdentity with Args whose RepoDir is not a git repository, whose From/To/Commit refs do not exist, or when the underlying git command (via GitRunner) fails during diff parsing (e.g. empty or corrupt repo, network fetch failure for remote refs).","commonSituations":"CI checking out a shallow clone missing the target commit; typo'd branch or SHA in --from/--to; running outside a git work tree; refs deleted between push and review (force-push).","solutions":["Run 'git rev-parse <ref>' in RepoDir for each ref in args to confirm they resolve before calling ResolveIdentity","Verify args.RepoDir is a valid git work tree ('git rev-parse --is-inside-work-tree')","Inspect the wrapped underlying error for the exact git failure (e.g. unknown revision)","For shallow clones, unshallow or fetch the missing commits before resolving","Confirm the uncommitted-sha / commit mode selection matches what the repo actually contains"],"exampleFix":"// before\nsealed, err := agent.ResolveIdentity(ctx, args)\n// after: pre-validate refs\nif out, err := git(args.RepoDir, \"rev-parse\", \"--verify\", args.From+\"^{commit}\"); err != nil {\n    return fmt.Errorf(\"bad ref %s: %w\", args.From, err)\n}\nsealed, err := agent.ResolveIdentity(ctx, args)","handlingStrategy":"validation","validationCode":"func canLoadDiffs(repoDir, from, to string) error {\n    if err := execGit(repoDir, \"rev-parse\", \"--is-inside-work-tree\"); err != nil {\n        return fmt.Errorf(\"not a git repo: %w\", err)\n    }\n    for _, ref := range []string{from, to} {\n        if ref == \"\" { continue }\n        if err := execGit(repoDir, \"rev-parse\", \"--verify\", ref+\"^{commit}\"); err != nil {\n            return fmt.Errorf(\"unresolvable ref %q: %w\", ref, err)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"sealed, err := agent.ResolveIdentity(ctx, args)\nif err != nil {\n    var loadErr error\n    if errors.As(err, &loadErr) && strings.Contains(err.Error(), \"load diffs:\") {\n        return fmt.Errorf(\"cannot admit run: %w\", err)\n    }\n    return err\n}","preventionTips":["Always verify From/To/Commit refs resolve before admission","Avoid shallow clones in CI, or fetch the review range explicitly","Run from a valid git work tree (RepoDir must exist and be a repo)","Check errors.Is/As on the wrapped cause for precise diagnostics"],"tags":["git","diff-loading","resume"],"backgroundTag":"git-ref-not-found","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}