Skip to content

feat(cursor-origin): List a pull request's files and commits - #143

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

wedamija merged 1 commit into
mainfrom
danf/origin-provider-pr-diff

Conversation

@wedamija

Copy link
Copy Markdown
Member

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.

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.
@wedamija
wedamija requested a review from a team as a code owner September 24, 2026 22:52
return PullRequestFile(
filename=raw["filename"],
status=CURSOR_ORIGIN_FILE_STATUS_MAP.get(raw["status"], "unknown"),
patch=raw["patch"] or None,

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 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.

@wedamija
wedamija merged commit 2f9aeca into main Sep 25, 2026
15 checks passed
@wedamija
wedamija deleted the danf/origin-provider-pr-diff branch September 25, 2026 17:05
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