alibaba/open-code-review · error
sessions belong to different repositories: %s was recorded i
Error message
sessions belong to different repositories: %s was recorded in %s, %s in %s
What it means
runSessionCompare refuses to compare two sessions recorded in different repositories (beforeSummary.RepoDir != afterSummary.RepoDir), because comparing findings across repos is meaningless. This is a deliberate guard, not an I/O failure; a differing review mode only warns, but a differing repo dir is fatal.
Source
Thrown at cmd/opencodereview/session_cmd.go:251
func runSessionCompare(beforeID, afterID string) error {
resolvedRepo, err := resolveWorkingDirForSession(sessionCompareRepoDir)
if err != nil {
return err
}
beforeSummary, err := session.LoadSummary(resolvedRepo, beforeID)
if err != nil {
return fmt.Errorf("load session %q: %w", beforeID, err)
}
afterSummary, err := session.LoadSummary(resolvedRepo, afterID)
if err != nil {
return fmt.Errorf("load session %q: %w", afterID, err)
}
// Comparing findings across repositories is meaningless, so it is an error
// rather than a warning. A different review mode or range still compares
// usefully (a full scan against a diff run, say), so that only warns.
if beforeSummary.RepoDir != afterSummary.RepoDir {
return fmt.Errorf("sessions belong to different repositories: %s was recorded in %s, %s in %s",
beforeID, beforeSummary.RepoDir, afterID, afterSummary.RepoDir)
}
if beforeSummary.ReviewMode != afterSummary.ReviewMode {
// stderr, never stdout: --json output is piped into other tools.
fmt.Fprintf(os.Stderr, "[ocr] WARNING review modes differ (%s vs %s); the two runs may not have looked at the same files\n",
displayMode(beforeSummary.ReviewMode), displayMode(afterSummary.ReviewMode))
}
beforeComments, err := session.LoadComments(resolvedRepo, beforeID)
if err != nil {
return fmt.Errorf("load session %q: %w", beforeID, err)
}
afterComments, err := session.LoadComments(resolvedRepo, afterID)
if err != nil {
return fmt.Errorf("load session %q: %w", afterID, err)
}
result := session.Compare(beforeComments, afterComments, reviewedPaths(afterSummary))
View on GitHub (pinned to 5cf97d0d15)
Solutions
- Compare only sessions recorded in the same repository; check each summary's RepoDir before comparing
- Re-record both sessions in the same repo/checkout
- If the repos are actually the same project, pick a single canonical clone and store sessions there
Example fix
// before ocr session compare s1 s2 // s1 in /work/a, s2 in /work/b // after cd /work/a && ocr session compare s1 s2 // both recorded here
Defensive patterns
Strategy: validation
Validate before calling
b, _ := session.LoadSummary(repo, beforeID)
a, _ := session.LoadSummary(repo, afterID)
if b.RepoDir != a.RepoDir {
return fmt.Errorf("refusing: %s vs %s", b.RepoDir, a.RepoDir)
} Try / catch
// parse the wrapped sentinel before proceeding
if strings.Contains(err.Error(), "sessions belong to different repositories") {
// surface both RepoDirs to the user and abort
} Prevention
- Store and compare sessions within a single canonical clone/worktree
- Check each summary's RepoDir programmatically before invoking compare
- Don't mix session IDs across projects in scripts
When it happens
Trigger: ocr session compare where the two loaded session summaries point at different RepoDir values — e.g. comparing a session from repo A with one from repo B, or from two distinct clones/worktrees of the same project.
Common situations: Running compare from a different checkout than where the sessions were made; passing IDs from two unrelated projects; duplicated worktrees.
Related errors
- %w (run 'ocr session list' to see available sessions)
- background file %q is a directory, not a file
- background file %q is %d bytes, exceeding the maximum of %d
- invalid scan template: %w
- load resume session: %w (run 'ocr session list' to see avail
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/3a2ac052bf606b90.
Report an issue: GitHub.