From e4ac3bfeed812794fd1b41da00f6f60e7b5e17d6 Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Thu, 11 Sep 2025 10:31:46 +0100 Subject: [PATCH] github: handle user opting out of github API in private_repo check Today we get a sorbet error when the user opts out, because `json` is `{}`, so `json["private"]` is `nil`. Given this function is used to check whether to send analytics, I assume we should default to treating the repo as a private repo. Refs: https://github.com/homebrew/brew/blob/8ef7a9dbd42cec14b745867b8c9ef4077074770e/Library/Homebrew/utils/github/api.rb#L276 --- Library/Homebrew/utils/github.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 1071ea9e7f..d0c72bbcb0 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -119,10 +119,11 @@ module GitHub API.open_rest(url, data:, scopes:) end + # We default to private if we aren't sure or if the GitHub API is disabled. sig { params(full_name: String).returns(T::Boolean) } def self.private_repo?(full_name) uri = url_to "repos", full_name - API.open_rest(uri) { |json| json["private"] } + API.open_rest(uri) { |json| json["private"].nil? || json["private"] } end def self.search_query_string(*main_params, **qualifiers)