alibaba/open-code-review · error
session id is required
Error message
session id is required
What it means
SessionFilePath validates its inputs before building the JSONL path under ~/.opencodereview/<sessions>/<encoded-repo>; an empty sessionID cannot map to a file, so it fails fast with this sentinel-style error. It is used by LoadComments, LoadSummary, LoadDetail and loadResumeState to locate a persisted session. Hitting it means the caller passed an empty/lost session ID instead of a real one.
Source
Thrown at internal/session/resume.go:83
ReviewMode string `json:"reviewMode"`
DiffFrom string `json:"diffFrom"`
DiffTo string `json:"diffTo"`
DiffCommit string `json:"diffCommit"`
ScanPaths *[]string `json:"scanPaths"`
FilePath string `json:"filePath"`
OldPath string `json:"oldPath"`
NewPath string `json:"newPath"`
Fingerprint string `json:"fingerprint"`
SourceSessionID string `json:"sourceSessionId"`
Error string `json:"error"`
Comments []model.LlmComment `json:"comments"`
RunManifest *RunManifest `json:"run_manifest"`
}
// SessionFilePath returns the JSONL path for a persisted session.
func SessionFilePath(repoDir, sessionID string) (string, error) {
if sessionID == "" {
return "", fmt.Errorf("session id is required")
}
home, err := os.UserHomeDir()
if err != nil {
return "", fmt.Errorf("resolve home dir: %w", err)
}
return filepath.Join(home, ".opencodereview", sessionSubDir, encodeRepoPath(repoDir), sessionID+".jsonl"), nil
}
// LoadResumeState replays a previous session JSONL into a fingerprint index. A
// record that cannot be parsed fails the load: with nothing to arbitrate coverage,
// a dropped line is indistinguishable from a checkpoint that was never written,
// and the pair it may have belonged to — a review_item_failed retracting an
// earlier done record — cannot be reconstructed from the rest of the file.
func LoadResumeState(repoDir, sessionID string) (*ResumeState, error) {
return loadResumeState(repoDir, sessionID, false)
}
// LoadReviewResumeState replays a review session, dropping records it cannotView on GitHub (pinned to 5cf97d0d15)
Solutions
- Pass a non-empty session ID (the UUID returned when the session was created / printed by the previous run)
- Guard the call site: if sessionID == "" skip resume instead of calling the loader
- Check where the session ID is stored (env/config) and fix the empty value at the source
- List existing sessions in ~/.opencodereview/<sessions>/<encoded-repo>/ to find the correct <sessionID>.jsonl
Example fix
// before
path, err := session.SessionFilePath(repoDir, sessionID) // sessionID == ""
// after
if sessionID == "" { return errors.New("no previous session to resume") }
path, err := session.SessionFilePath(repoDir, sessionID) Defensive patterns
Strategy: validation
Validate before calling
if sessionID == "" {
return errors.New("no session id available; skip resume or run a new session")
}
path, err := session.SessionFilePath(repoDir, sessionID) Try / catch
path, err := session.SessionFilePath(repoDir, sessionID)
if err != nil {
if strings.Contains(err.Error(), "session id is required") {
log.Printf("empty session id: %v", err)
}
} Prevention
- Persist the session ID from the first run before attempting resume
- Fail fast on empty IDs at config-parse time instead of at the loader
- Keep the session ID in a typed struct so an empty value is explicit
When it happens
Trigger: Calling SessionFilePath(repoDir, ""), or calling any loader (LoadComments/LoadSummary/LoadDetail/loadResumeState) after resume state was never established and the session ID variable defaulted to the empty string.
Common situations: Resuming before a first session was ever persisted; a config file or env var that should carry the session ID is empty; parsing code that failed to extract the session ID from a previous run's output and silently stored "".
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- --max-tokens must be a non-negative integer
- invalid line range: start_line %d is greater than end_line %
- background file %q is a directory, not a file
- background file %q is %d bytes, exceeding the maximum of %d
- invalid max_tokens %q: must be a positive integer
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/e1a78a7833cf1054.
Report an issue: GitHub.