88
99from sentry import options
1010from sentry .models .organization import Organization
11- from sentry .seer .agent .client_models import SeerRunState
1211from sentry .seer .agent .client_utils import fetch_run_status
1312from sentry .seer .pr_links import link_seer_run_to_pull_request
1413
@@ -81,7 +80,6 @@ def call_on_completion_hook(
8180 module_path : str ,
8281 organization_id : int ,
8382 run_id : int ,
84- state : dict | None = None ,
8583 allowed_prefixes : tuple [str , ...] = ("sentry." ,),
8684) -> None :
8785 """Dynamically import and call an on-completion hook class.
@@ -90,8 +88,6 @@ def call_on_completion_hook(
9088 module_path: Full module path to the hook class (e.g., "sentry.api.MyHook")
9189 organization_id: Organization ID to load and pass to the hook
9290 run_id: The run ID that completed
93- state: The completed run's serialized state, if Seer pushed it; lets us
94- skip re-querying Seer for PR linking.
9591 allowed_prefixes: Tuple of allowed module path prefixes for security
9692 """
9793 # Only allow imports from approved package prefixes
@@ -106,7 +102,7 @@ def call_on_completion_hook(
106102 except Organization .DoesNotExist :
107103 raise ValueError (f"Organization with id { organization_id } does not exist" )
108104
109- _link_run_pull_requests (organization , run_id , state )
105+ _link_run_pull_requests (organization , run_id )
110106
111107 # Split module path and class name
112108 parts = module_path .rsplit ("." , 1 )
@@ -130,19 +126,13 @@ def call_on_completion_hook(
130126 hook_class .execute (organization , run_id )
131127
132128
133- def _link_run_pull_requests (
134- organization : Organization , run_id : int , state : dict | None
135- ) -> None :
136- """Record a SeerRunPullRequest for each PR the completed run opened.
137-
138- Uses the run state Seer pushed with the hook call; falls back to querying Seer
139- when it wasn't provided.
140- """
129+ def _link_run_pull_requests (organization : Organization , run_id : int ) -> None :
130+ """Record a SeerRunPullRequest for each PR the completed run opened."""
141131 if options .get ("seer.run-pr-link.killswitch.enabled" ):
142132 return
143133
144134 try :
145- run_state = SeerRunState ( ** state ) if state is not None else fetch_run_status (run_id , organization )
135+ run_state = fetch_run_status (run_id , organization )
146136 except Exception :
147137 logger .exception (
148138 "seer.pr_link.state_unavailable" ,
0 commit comments