afragen / git-updater-gitlab

GitLab API for Git Updater plugin
MIT License
7 stars 5 forks source link

404 when trying to install a plugin #4

Closed ITaluone closed 6 months ago

ITaluone commented 8 months ago

Hi

I am getting a 404 when I try to install a plugin from an internal gitlab server.

This is what I get: http://gitlab/api/v4/projects/[username]%2F[repository-slug]/repository/archive.zip?sha=main …

Note: The %2F is literally there in the error message. Also note, that this url is wrong either. The correct URL would be: http://gitlab/api/v4/projects/[project_id]/repository/archive.zip?sha=main

afragen commented 8 months ago

https://docs.gitlab.com/ee/api/rest/index.html#namespaced-path-encoding

afragen commented 8 months ago

404 is usually an authentication error. It may be due to a copy/paste issue or a permissions issue with the access token.

afragen commented 8 months ago

Example.

Updating Plugin Test GitLab Private (1/1)

Test GitLab Private updated successfully. More details.

Downloading update from https://gitlab.com/api/v4/projects/afragen%2Ftest-gitlab-private/repository/archive.zip?sha=master…
Unpacking the update…
Installing the latest version…
Removing the old version of the plugin…
Plugin updated successfully.
All updates have been completed.
IT-VBFK commented 8 months ago

404 is usually an authentication error. It may be due to a copy/paste issue or a permissions issue with the access token.

No, unfortunately not. I does not even work with a public repo

copy/paste issue

And no: Used the gitlab copy functionality..

or a permissions issue with the access token

Also no: tried read, read_repositoryand a "full" permission token

afragen commented 8 months ago

Can you share the plugin headers?

IT-VBFK commented 8 months ago

Wait.. must the plugin header from a plugin which I want to install already contain the "Gitlab Plugin URI" header?

afragen commented 8 months ago

Can you share the fields you are using to install?

Do you have the branch and slug fields correct?

ITaluone commented 8 months ago

Can you share the plugin headers?

Here the most sensible header data

/**
 * ...
 * GitLab Plugin URI: http://gitlab/[username]/changelogs
 * Primary Branch: main
 * Version:           1.0.5
 * ...
 */

Can you share the fields you are using to install?

What do you mean? I use all fields (plugin URI, the branch (since the branch is main), set the select to GitLab and tried both with and without access token (for internal and public repo)

I tested the archive download on my local PC and the URI which the plugin tries to download from doesn't work while the download with project_id works

afragen commented 8 months ago

What is the default branch in your repository?

ITaluone commented 8 months ago

The default branch is main

Edit: I have forgotten to include the Primary Branch: in the snippet above.. corrected that

afragen commented 8 months ago

Perhaps it might be easier to give me some sort of temporary access so I can look and test?

ITaluone commented 6 months ago

Hello again

I now had time to test this again and I found the issue. I successfully integrated this plugin updater into other WP plugins of mine, so I compared the Plugin URL and the GitLab Plugin URL of both plugins.

And the difference was: Working: http://gitlab/ Not-working: http://gitlab.internaldomain.local

So apparently this plugin has issues with fully qualified internal domains names.

But anyway: thanks for you quick reactions and attempts to help.. Really appreciated 👍

Edit: The real problem was: In https://github.com/afragen/git-updater/issues/957 I realized, that WP rejects plugin updates from http source. You provided a gist which I adapted for my environment. But I don't included the FQDN in there. After adding it all works like a charm :)