Skip to content

Communicate SourceCodeManager's capabilities through RPC#111303

Merged
jacquev6 merged 2 commits into
masterfrom
jacquev6/scm-platform/rpc-capabilities
Mar 24, 2026
Merged

Communicate SourceCodeManager's capabilities through RPC#111303
jacquev6 merged 2 commits into
masterfrom
jacquev6/scm-platform/rpc-capabilities

Conversation

@jacquev6

@jacquev6 jacquev6 commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator

This exposes the capabilities of a given provider through the SCM RPC. It's used in https://github.com/getsentry/seer/pull/5393.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 23, 2026
@jacquev6 jacquev6 marked this pull request as ready for review March 23, 2026 16:03
@jacquev6 jacquev6 requested a review from a team as a code owner March 23, 2026 16:03
@jacquev6 jacquev6 requested a review from cmanallen March 23, 2026 16:03
@github-actions

Copy link
Copy Markdown
Contributor

Backend Test Failures

Failures on b0285b2 in this run:

tests/sentry/scm/unit/test_scm_actions.py::test_get_capabilitieslog
tests/sentry/scm/unit/test_scm_actions.py:781: in test_get_capabilities
    assert list(get_capabilities(SourceCodeManager(BaseTestProvider()))) == [
E   AssertionError: assert ['CompareComm...GitTree', ...] == ['CompareComm...rotocol', ...]
E     
E     At index 0 diff: 'CompareCommits' != 'CompareCommitsProtocol'
E     
E     Full diff:
E       [
E     -     'CompareCommitsProtocol',
E     ?                    --------
E     +     'CompareCommits',
E     -     'CreateBranchProtocol',
E     ?                  --------
E     +     'CreateBranch',
E     -     'CreateCheckRunProtocol',
E     ?                    --------
E     +     'CreateCheckRun',
E     -     'CreateGitBlobProtocol',
E     ?                   --------
E     +     'CreateGitBlob',
E     -     'CreateGitCommitProtocol',
E     ?                     --------
E     +     'CreateGitCommit',
E     -     'CreateGitTreeProtocol',
E     ?                   --------
E     +     'CreateGitTree',
E     -     'CreateIssueCommentProtocol',
E     ?                        --------
E     +     'CreateIssueComment',
E     -     'CreateIssueCommentReactionProtocol',
E     ?                                --------
E     +     'CreateIssueCommentReaction',
E     -     'CreateIssueReactionProtocol',
E     ?                         --------
E     +     'CreateIssueReaction',
E     -     'CreatePullRequestCommentProtocol',
E     ?                              --------
E     +     'CreatePullRequestComment',
E     -     'CreatePullRequestCommentReactionProtocol',
E     ?                                      --------
E     +     'CreatePullRequestCommentReaction',
E     -     'CreatePullRequestDraftProtocol',
E     ?                            --------
E     +     'CreatePullRequestDraft',
E     -     'CreatePullRequestProtocol',
E     ?                       --------
E     +     'CreatePullRequest',
E     -     'CreatePullRequestReactionProtocol',
E     ?                               --------
E     +     'CreatePullRequestReaction',
... (100 more lines)

Comment thread src/sentry/scm/actions.py Outdated

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Test expectations contradict removesuffix("Protocol") in code
    • Updated test_get_capabilities to expect protocol names without the Protocol suffix, matching the implemented and documented get_capabilities behavior used by get_capabilities_v1.

Create PR

Or push these changes by commenting:

@cursor push a21f8561c9
Preview (a21f8561c9)
diff --git a/tests/sentry/scm/unit/test_scm_actions.py b/tests/sentry/scm/unit/test_scm_actions.py
--- a/tests/sentry/scm/unit/test_scm_actions.py
+++ b/tests/sentry/scm/unit/test_scm_actions.py
@@ -779,53 +779,53 @@
 
 def test_get_capabilities():
     assert list(get_capabilities(SourceCodeManager(BaseTestProvider()))) == [
-        "CompareCommitsProtocol",
-        "CreateBranchProtocol",
-        "CreateCheckRunProtocol",
-        "CreateGitBlobProtocol",
-        "CreateGitCommitProtocol",
-        "CreateGitTreeProtocol",
-        "CreateIssueCommentProtocol",
-        "CreateIssueCommentReactionProtocol",
-        "CreateIssueReactionProtocol",
-        "CreatePullRequestCommentProtocol",
-        "CreatePullRequestCommentReactionProtocol",
-        "CreatePullRequestDraftProtocol",
-        "CreatePullRequestProtocol",
-        "CreatePullRequestReactionProtocol",
-        "CreateReviewCommentFileProtocol",
-        "CreateReviewCommentReplyProtocol",
-        "CreateReviewProtocol",
-        "DeleteIssueCommentProtocol",
-        "DeleteIssueCommentReactionProtocol",
-        "DeleteIssueReactionProtocol",
-        "DeletePullRequestCommentProtocol",
-        "DeletePullRequestCommentReactionProtocol",
-        "DeletePullRequestReactionProtocol",
-        "GetBranchProtocol",
-        "GetCheckRunProtocol",
-        "GetCommitProtocol",
-        "GetCommitsByPathProtocol",
-        "GetCommitsProtocol",
-        "GetFileContentProtocol",
-        "GetGitCommitProtocol",
-        "GetIssueCommentReactionsProtocol",
-        "GetIssueCommentsProtocol",
-        "GetIssueReactionsProtocol",
-        "GetPullRequestCommentReactionsProtocol",
-        "GetPullRequestCommentsProtocol",
-        "GetPullRequestCommitsProtocol",
-        "GetPullRequestDiffProtocol",
-        "GetPullRequestFilesProtocol",
-        "GetPullRequestProtocol",
-        "GetPullRequestReactionsProtocol",
-        "GetPullRequestsProtocol",
-        "GetTreeProtocol",
-        "MinimizeCommentProtocol",
-        "RequestReviewProtocol",
-        "UpdateBranchProtocol",
-        "UpdateCheckRunProtocol",
-        "UpdatePullRequestProtocol",
+        "CompareCommits",
+        "CreateBranch",
+        "CreateCheckRun",
+        "CreateGitBlob",
+        "CreateGitCommit",
+        "CreateGitTree",
+        "CreateIssueComment",
+        "CreateIssueCommentReaction",
+        "CreateIssueReaction",
+        "CreatePullRequestComment",
+        "CreatePullRequestCommentReaction",
+        "CreatePullRequestDraft",
+        "CreatePullRequest",
+        "CreatePullRequestReaction",
+        "CreateReviewCommentFile",
+        "CreateReviewCommentReply",
+        "CreateReview",
+        "DeleteIssueComment",
+        "DeleteIssueCommentReaction",
+        "DeleteIssueReaction",
+        "DeletePullRequestComment",
+        "DeletePullRequestCommentReaction",
+        "DeletePullRequestReaction",
+        "GetBranch",
+        "GetCheckRun",
+        "GetCommit",
+        "GetCommitsByPath",
+        "GetCommits",
+        "GetFileContent",
+        "GetGitCommit",
+        "GetIssueCommentReactions",
+        "GetIssueComments",
+        "GetIssueReactions",
+        "GetPullRequestCommentReactions",
+        "GetPullRequestComments",
+        "GetPullRequestCommits",
+        "GetPullRequestDiff",
+        "GetPullRequestFiles",
+        "GetPullRequest",
+        "GetPullRequestReactions",
+        "GetPullRequests",
+        "GetTree",
+        "MinimizeComment",
+        "RequestReview",
+        "UpdateBranch",
+        "UpdateCheckRun",
+        "UpdatePullRequest",
     ]
 
     class IncapableProvider:

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread tests/sentry/scm/unit/test_scm_actions.py
Comment thread src/sentry/scm/actions.py Outdated
"""
for protocol in ALL_PROTOCOLS:
if isinstance(scm, protocol):
yield protocol.__name__.removesuffix("Protocol")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should keep the type names the same to simplify usage patterns across the platform's interfaces.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in de097a7.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread src/sentry/scm/actions.py
"""Get the names of the protocols implemented by the given SourceCodeManager."""
for protocol in ALL_PROTOCOLS:
if isinstance(scm, protocol):
yield protocol.__name__

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.

New function missing from module's __all__ export list

Low Severity

The newly added get_capabilities function is not included in the __all__ tuple at the bottom of actions.py. Every other public function in this module is listed in __all__, making this an inconsistency. While explicit imports in rpc.py and tests work fine, anyone using wildcard imports from this module would not get get_capabilities.

Fix in Cursor Fix in Web

# If a method of SourceCodeManager accepts only JSON-serializable arguments, by names, and
# returns a JSON-serializable type, then it can be listed here directly.
# Else, an adapter function must be used.
"get_capabilities_v1": lambda scm: sorted(get_capabilities(scm)),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Curious about this sort call. I assume its a QOL change for the RPC. Could the same be said for local Sentry usage? Do we even want to expose this for local Sentry usage (i.e. should get_capabilities be inlined in the RPC only)?

I have no opinions. We can merge as is.

@jacquev6 jacquev6 merged commit e770797 into master Mar 24, 2026
64 checks passed
@jacquev6 jacquev6 deleted the jacquev6/scm-platform/rpc-capabilities branch March 24, 2026 14:35
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants