@@ -397,15 +397,23 @@ def get_repo_info(self, repo_slug: str, default_branch: str = "socket-default-br
397397 # raise Exception(f"Failed to get repository info: {response.status}, message: {response.message}")
398398 except APIFailure :
399399 log .warning (f"Failed to get repository { repo_slug } , attempting to create it" )
400- create_response = self .sdk .repos .post (self .config .org_slug , name = repo_slug , default_branch = default_branch , use_types = True )
401- if not create_response .success :
402- log .error (f"Failed to create repository: { create_response .status } " )
403- log .error (create_response .message )
404- raise Exception (
405- f"Failed to create repository: { create_response .status } , message: { create_response .message } "
406- )
407- else :
408- return create_response .data
400+ try :
401+ # Remove use_types=True since post() doesn't support it
402+ create_response = self .sdk .repos .post (self .config .org_slug , name = repo_slug , default_branch = default_branch )
403+
404+ # Check if the response is empty (failure) or has content (success)
405+ if not create_response :
406+ log .error ("Failed to create repository: empty response" )
407+ raise Exception ("Failed to create repository: empty response" )
408+ else :
409+ # If we got here, create_response is a dictionary with the repository data
410+ return create_response # This is already the repository data
411+
412+ except APIFailure as e :
413+ # Handle API failures from the post request
414+ log .error (f"API failure while creating repository: { e } " )
415+ sys .exit (2 ) # Exit here with code 2. Code 1 indicates a successfully-detected security issue.
416+
409417 return response .data
410418
411419 def get_head_scan_for_repo (self , repo_slug : str ) -> str :
0 commit comments