Skip to content

fix(session): return empty slice for nonexistent sessions directory - #1699

Open
ege-arhan wants to merge 1 commit into
alibaba:mainfrom
ege-arhan:fix/issue-1696
Open

ege-arhan wants to merge 1 commit into
alibaba:mainfrom
ege-arhan:fix/issue-1696

Conversation

@ege-arhan

Copy link
Copy Markdown

Fixes #1696

Summary

When a repository has no prior review sessions, internal/session.ListSessions previously returned nil, nil on the os.IsNotExist(err) path. When serialized by ocr session list --json, this produced JSON null instead of an empty array [], making CLI consumers handle two different shapes for an empty list of sessions.

Changes

  • Updated ListSessions to return an empty initialized slice []Summary{} when the sessions directory does not exist.
  • Updated TestListSessions_EmptyRepoReturnsEmptySlice in internal/session to verify non-nil empty slice.
  • Added TestRunSessionList_JSON_MissingSessionsDirReturnsEmptyArray in cmd/opencodereview to ensure the JSON command consistently outputs [].

@CLAassistant

CLAassistant commented Oct 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(session): session list --json prints null for a repo with no sessions, but [] once the directory exists

2 participants