feat(cursor-origin): List a pull request's files and commits - #143
Merged
Merged
Conversation
Add support for listing the files and commits in a pull request. Origin does not provide blob SHAs for changed files, so `sha` is left empty.
| return PullRequestFile( | ||
| filename=raw["filename"], | ||
| status=CURSOR_ORIGIN_FILE_STATUS_MAP.get(raw["status"], "unknown"), | ||
| patch=raw["patch"] or None, |
There was a problem hiding this comment.
Bug: The code uses direct dictionary access raw["patch"], which will raise a KeyError if the API response for a file (e.g., a binary file) omits the patch key.
Severity: HIGH
Suggested Fix
Use the safe .get() method to access the patch key, for example: raw.get("patch"). This will return None if the key is absent, preventing a KeyError and ensuring more robust handling of API responses.
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#L756
Potential issue: The `map_pull_request_file` function directly accesses the `patch` key
from the API response dictionary using `raw["patch"]`. This will raise a `KeyError` if
the key is not present in the response. Based on similar APIs like GitHub's, the `patch`
key is often omitted for binary files or very large diffs. Since this function interacts
with a new, unproven API endpoint, assuming the `patch` key is always present is risky
and likely to cause failures when processing pull requests containing such files. The
same unsafe access pattern is also present in the `map_commit_file` function.
Also affects:
src/scm/providers/cursor_origin/provider.py:745
Did we get this right? 👍 / 👎 to inform future reviews.
billyvg
approved these changes
Sep 24, 2026
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 listing the files and commits in a pull request. Origin does not provide blob SHAs for changed files, so
shais left empty.