YahnisElsts / plugin-update-checker

A custom update checker for WordPress plugins. Useful if you don't want to host your project in the official WP repository, but would still like it to support automatic updates. Despite the name, it also works with themes.
MIT License
2.26k stars 410 forks source link

GitHub API Error: HTTP status code: 404. puc-github-http-error #423

Closed geraldopp closed 1 year ago

geraldopp commented 3 years ago

Hello. I am trying to connect my plugin with my private remote repo through Github. I haven't had any luck in achieving this. I created a Personal Access Token on Github and that is the token I am using in the config params. Other than that, my repository url is correct, I am not using any hooks in my plugins's main php file. I copied all the files in a folder inside my project with the exact same naming convention. I created a tag on GitHub with my current stable tag number. There is nothing else I can think of that might be causing this error. This is what I am getting:

Could not determine if updates are available for Dinner in the Sky Reservations.

GitHub API error. Base URL: "/repos/:user/:repo/releases/latest", HTTP status code: 404. puc-github-http-error GitHub API error. Base URL: "/repos/:user/:repo/tags", HTTP status code: 404. puc-github-http-error GitHub API error. Base URL: "/repos/:user/:repo/branches/master", HTTP status code: 404. puc-github-http-error Could not retrieve version information from the repository. This usually means that the update checker either can't connect to the repository or it's configured incorrectly. puc-no-update-source

Please help

YahnisElsts commented 3 years ago

Most likely, either the repository URL or the access token is incorrect.

Could you show the code that you use to initialize the update checker? You can replace the access token with a placeholder value before posting.

rpc4mv commented 3 years ago

Running into the same issue. I created a personal access token following these steps.

And have this at the bottom of my functions.php file:

$check_updates = Puc_v4_Factory::buildUpdateChecker(
    'https://github.com/Dwellers/wp-yup-theme',
    __FILE__,
    'yup'
);
$check_updates->setAuthentication('ghp_****');

I verified my access token works using

curl -u rpc4mv:ghp_**** https://api.github.com/repos/Dwellers/wp-yup-theme/branches/master
YahnisElsts commented 3 years ago

Assuming that both the repository URL and the token are correct, I don't know what could cause a 404 error in this context. I tested it with a private repository just before writing this comment and that worked fine, so it's probably not an API compatibility issue.

Maybe you could try logging the HTTP requests and see if the API URL or the full 404 response provides any clues?

JiveDig commented 1 year ago

I'm seeing this with all (most) of my plugins using PUC. Many customers are seeing it as well. This is with all public repos too. Happy to test but not exactly sure how. Can you give me some direction on what to look into?

dHwTHHms

YahnisElsts commented 1 year ago

If you can reliably reproduce the problem, I recommend setting up HTTP request logging and checking what exactly GitHub isn't happy with. There should be more details in the API response body.

There was a "Core Control" plugin that I used to use to log HTTP requests sent by WP plugins, but it's no longer available. Maybe you could use Log HTTP Requests or, for a local site, something like Wireshark.

JiveDig commented 1 year ago

I'm seeing this on plugins that use Releases and others that do not and strictly use a version number in the plugin header.

JiveDig commented 1 year ago

Okay wow, that was easy, thanks.

{
  "headers": {},
  "body": "{\"message\":\"API rate limit exceeded for {IP removed for privacy}. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)\",\"documentation_url\":\"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting\"}\n",
  "response": {
    "code": 403,
    "message": "Forbidden"
  },
  "cookies": [],
  "filename": null,
  "http_response": {
    "data": null,
    "headers": null,
    "status": null
  }
}

Seems like the error doesn't really match the response. It would be nice if it said something about hitting an API limit and to try again in an hour or something.

YahnisElsts commented 1 year ago

Right now PUC doesn't distinguish between different GitHub API errors. It just treats them all as failures.

I'll make a note to perhaps show different error messages if the error was caused by rate limiting specifically. Still, most users shouldn't usually see these errors unless they're manually checking for updates. The errors shouldn't show up during automatic checks - PUC should just retry later.

JiveDig commented 1 year ago

Okay great, thanks. FWIW I've been using PUC for a few years now and it's been awesome. Thanks so much for sharing it, and your continued updates/support 🏆 ❤️

YahnisElsts commented 1 year ago

Thanks, it's good to hear that the library is useful to people!

I'll close this issue now. The person who originally opened it hasn't commented here in a year, so, presumably, they have also resolved it somehow, or it's no longer relevant.