Skip to content

fix(session): print an empty items array from session show --json - #1792

Merged
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
kevin9327:fix/session-show-json-empty-items
Oct 30, 2026
Merged

lizhengfeng101 merged 2 commits into
alibaba:mainfrom
kevin9327:fix/session-show-json-empty-items

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

Summary

ocr session show <id> --json prints "items": null when the session recorded no per-file items (for example a run that ended before any file was reviewed). ocr session comments --json and ocr session compare --json already emit [] for empty lists, so scripts that iterate .items break only on this command.

Fix

Normalize a nil items slice to an empty slice before encoding, the same way runSessionComments handles filtered.

Test

Added TestRunSessionShow_JSONNoItemsIsArray, which finalizes a session without items and checks the raw items value. It fails before the change (items = null, want []) and passes after. go test -run TestRunSession ./cmd/opencodereview passes.

This is separate from #1696 (session list --json), which only touches the list path.

AI-assisted: drafted with an AI coding assistant; I reproduced the issue, reviewed the change and ran the tests myself.

@github-actions

Copy link
Copy Markdown
Contributor

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

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 216dcf5 into alibaba:main Oct 30, 2026
11 checks passed
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.

2 participants