Protect from invalid github org response

Attempt to fix #287
This commit is contained in:
Max Wofford
2025-06-08 20:56:09 -04:00
parent a51cb8c897
commit e43f23065d

View File

@@ -67,6 +67,15 @@ class AttemptProjectRepoMappingJob < ApplicationJob
.get("https://api.github.com/users/#{@user.github_username}/orgs")
Rails.logger.info "GitHub orgs response: #{response.body}"
JSON.parse(response.body)
return [] unless response.status.success?
parsed_response = JSON.parse(response.body)
return [] unless parsed_response.is_a?(Array)
parsed_response
rescue JSON::ParserError => e
Rails.logger.error "Failed to parse GitHub orgs response: #{e.message}"
[]
end
end