diff --git a/CHANGES.md b/CHANGES.md index 341f24f9c..44065aee4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ #### [unreleased] * remove `git_updater_plugin_updates` and `git_updater_theme_updates` options, see [#1119](https://github.com/afragen/git-updater/issues/1119) * add `gu_plugin_name()` to return plugin name, slug or slug-didhash +* include the reason why an API data response is incorrect #### 12.20.2 / 2025-12-08 * harden REST API data for versions if relesase_assets and tags are empty -- this can happen if too many tags are created that aren't semver format diff --git a/src/Git_Updater/REST/REST_API.php b/src/Git_Updater/REST/REST_API.php index d880f068d..4e1bf2114 100644 --- a/src/Git_Updater/REST/REST_API.php +++ b/src/Git_Updater/REST/REST_API.php @@ -457,8 +457,15 @@ public function get_api_data( WP_REST_Request $request ) { add_filter( 'gu_disable_wpcron', '__return_false' ); $repo_data = Singleton::get_instance( 'Fragen\Git_Updater\Base', $this )->get_remote_repo_meta( $gu_repos[ $slug ] ); - if ( ! is_object( $repo_data ) || '0.0.0' === $repo_data->remote_version ) { - return (object) [ 'error' => 'API data response is incorrect.' ]; + $api_data_incorrect_error = (object) [ 'error' => 'API data response is incorrect.' ]; + if ( ! is_object( $repo_data ) ) { + $repo_data_type = gettype( $repo_data ); + $api_data_incorrect_error->error .= " Object expected, {$repo_data_type} returned."; + return $api_data_incorrect_error; + } + if ( '0.0.0' === $repo_data->remote_version ) { + $api_data_incorrect_error->error .= ' The remote version is "0.0.0".'; + return $api_data_incorrect_error; } $last_updated = ! empty( $repo_data->created_at ) ? reset( $repo_data->created_at ) : $repo_data->last_updated;