Skip to content

feat(cursor-origin): Read a commit with its changed files - #149

Merged
wedamija merged 1 commit into
mainfrom
danf/origin-provider-commit-detail
Sep 25, 2026
Merged

wedamija merged 1 commit into
mainfrom
danf/origin-provider-commit-detail

Conversation

@wedamija

Copy link
Copy Markdown
Member

Add support for reading a single commit with its stats and changed files, and for listing a commit's changed files. Origin returns files separately, so the commit response includes only the first 100 files.

@wedamija
wedamija requested a review from a team as a code owner September 24, 2026 23:43
Comment on lines +496 to +497
pagination={"per_page": MAX_PAGE_SIZE},
request_options=request_options,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The code uses unsafe direct dictionary access (raw["stats"], raw["patch"]) on an API response, which will raise a KeyError if the keys are missing.
Severity: HIGH

Suggested Fix

Use the .get() method with a default value to safely access potentially missing keys from the API response. For example, access stats with stats = raw.get("stats") or {} and then additions=stats.get("additions"). Similarly, access the patch with patch=raw.get("patch").

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/scm/providers/cursor_origin/provider.py#L496-L497

Potential issue: The `get_commit` method and its helper `map_commit_file` in the Cursor
Origin provider use direct dictionary access to parse the API response. Specifically,
`raw["stats"]["additions"]`, `raw["stats"]["deletions"]`, and `raw["patch"]` are
accessed without checking if the keys exist. If the API returns a commit object without
a `stats` field (e.g., for an empty commit) or a file object without a `patch` field,
the application will raise a `KeyError` and crash while processing the commit. This
contrasts with the more defensive `.get()` approach used in other SCM providers like
GitHub.

Also affects:

  • src/scm/providers/cursor_origin/provider.py:523~523

Did we get this right? 👍 / 👎 to inform future reviews.

Add support for reading a single commit with its stats and changed files, and for listing a commit's changed files. Origin returns files separately, so the commit response includes only the first 100 files.
@wedamija
wedamija force-pushed the danf/origin-provider-commit-detail branch from 92b7410 to 0bdf035 Compare September 25, 2026 17:05
@wedamija
wedamija merged commit 08af78e into main Sep 25, 2026
14 of 15 checks passed
@wedamija
wedamija deleted the danf/origin-provider-commit-detail branch September 25, 2026 17:07
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