@@ -198,9 +198,9 @@ async def inner(data: dict):
198198 # ignore MRs based on title, labels, source and target branches
199199 if not should_process_pr_logic (data ):
200200 return JSONResponse (status_code = status .HTTP_200_OK , content = jsonable_encoder ({"message" : "success" }))
201-
202- if data [ ' object_attributes' ] .get ('action' ) in ['open' , 'reopen' ]:
203- url = data [ ' object_attributes' ] .get ('url' )
201+ object_attributes = data . get ( 'object_attributes' , {})
202+ if object_attributes .get ('action' ) in ['open' , 'reopen' ]:
203+ url = object_attributes .get ('url' )
204204 get_logger ().info (f"New merge request: { url } " )
205205 if is_draft (data ):
206206 get_logger ().info (f"Skipping draft MR: { url } " )
@@ -209,8 +209,8 @@ async def inner(data: dict):
209209 await _perform_commands_gitlab ("pr_commands" , PRAgent (), url , log_context , data )
210210
211211 # for push event triggered merge requests
212- elif data [ ' object_attributes' ] .get ('action' ) == 'update' and data [ ' object_attributes' ] .get ('oldrev' ):
213- url = data [ ' object_attributes' ] .get ('url' )
212+ elif object_attributes .get ('action' ) == 'update' and object_attributes .get ('oldrev' ):
213+ url = object_attributes .get ('url' )
214214 get_logger ().info (f"New merge request: { url } " )
215215 if is_draft (data ):
216216 get_logger ().info (f"Skipping draft MR: { url } " )
@@ -227,8 +227,8 @@ async def inner(data: dict):
227227 await _perform_commands_gitlab ("push_commands" , PRAgent (), url , log_context , data )
228228
229229 # for draft to ready triggered merge requests
230- elif data [ ' object_attributes' ] .get ('action' ) == 'update' and is_draft_ready (data ):
231- url = data [ ' object_attributes' ] .get ('url' )
230+ elif object_attributes .get ('action' ) == 'update' and is_draft_ready (data ):
231+ url = object_attributes .get ('url' )
232232 get_logger ().info (f"Draft MR is ready: { url } " )
233233
234234 # same as open MR
0 commit comments