feat(cursor-origin): Read a commit with its changed files - #149
Merged
Merged
Conversation
Comment on lines
+496
to
+497
| pagination={"per_page": MAX_PAGE_SIZE}, | ||
| request_options=request_options, |
There was a problem hiding this comment.
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.
giovanni-guidini
approved these changes
Sep 25, 2026
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
force-pushed
the
danf/origin-provider-commit-detail
branch
from
September 25, 2026 17:05
92b7410 to
0bdf035
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.