Skip to content
Prev Previous commit
Next Next commit
Handle 404 from GitHub API
  • Loading branch information
swissspidy committed Apr 30, 2025
commit 51482846ed93862a7ec60aa3e0daf1350756bfed
7 changes: 7 additions & 0 deletions src/WP_CLI/CommandWithUpgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,13 @@ protected function get_the_latest_github_version( $repo_slug ) {
);
}

if ( 404 === wp_remote_retrieve_response_code( $response ) ) {
return new \WP_Error(
$decoded_body->status,
$decoded_body->message
);
}

if ( null === $decoded_body ) {
return new \WP_Error( 500, 'Empty response received from GitHub.com API' );
}
Expand Down