v4 API: un-encoded dots (`.`) in a project name are not processed while downloading last job's artifacts; namespaced path encoding
Problem Statement
"Is it a bug or an expected behaviour that dots .
in project namespaced path need to be encoded for an API call?"
The question has been raised by a customer (internal ZD ticket) who observed this problematic/inconsistent behaviour while trying to download last job's artifacts on their self-managed instance.
The customer as well highlighted #35968 (closed) as a reference/similar problem.
Reach
This behaviour has been observed/verified in both Self-managed (v12.6.4) as well as GitLab.com
It is hard to estimate how many customers are using this specific functionality.
1.5 = Small reach (~5% to ~25%) ?
Impact
Fixing this bug (if confirmed to be a bug) the API would become more consistent and thus more lovable.
If not a bug, the documentation of namespaced path encoding as well as download last job's artifacts should be updated in order to describe this particular exception to the project namespaced path encoding.
0.5 = Low impact ?
Confidence
Verification in a local test environment as well as in GitLab.com has confirmed this behaviour.
Processing of dot(s) .
in a namespaced path is, however, inconsistent comparing to another API resources/methods where .
doesn't need to be encrypted.
See following ..
Self-managed (v12.6.4-ee) examples (for project namespaced-path root/my_project.01
:
API method | API URL call | Result |
---|---|---|
Download latest job artifacts | api/v4/projects/root%2Fmy_project.01/jobs/artifacts/master/download?job=prepare-job |
404 Not Found |
Download latest job artifacts | api/v4/projects/root%2Fmy_project%2E01/jobs/artifacts/master/download?job=prepare-job |
200 OK |
Get repo tags | api/v4/projects/root%2Fmy_project.01/repository/tags/ |
200 OK |
Get repo tags | api/v4/projects/root%2Fmy_project%2E01/repository/tags/ |
200 OK |
Get project users | api/v4/projects/root%2Fmy_project.01/users/ |
200 OK |
Get project users | api/v4/projects/root%2Fmy_project%2E01/users/ |
200 OK |
The "dotted" project name seems to be working in all API resource calls but the "download latest job artifacts", where only the encoded version is working.
GitLab.com examples:
Download latest job artifacts:
Project name with un-encoded .
-> 404
curl -L -H "Private-Token: <REDACTED>" "https://www.gitlab.com/api/v4/projects/vbrodsky%2Fdotted_project.01/jobs/artifacts/master/download?job=prepare-job"`
"error":"404 Not Found"}
Project name with encoded .
-> 200
curl -L -v -H "Private-Token: <REDACTED>" "https://www.gitlab.com/api/v4/projects/vbrodsky%2Fdotted_project%2E01/jobs/artifacts/master/download?job=prepare-job" > arts.zip
...
> GET /api/v4/projects/vbrodsky%2Fdotted_project%2E01/jobs/artifacts/master/download?job=prepare-job HTTP/1.1
> Host: gitlab.com
...
< HTTP/2 200
...
100 241 100 241 0 0 149 0 0:00:01 0:00:01 --:--:-- 149
...
Testing of repository/commits
and repository/users
confirmed that both are working with dots as well as encoded dots in the namespaced-path of the project.
100% = High confidence
Effort
I haven't been able to track down the problem in the code, thus cannot estimate how much effort would be needed in order to fix this.
It should be tested if any other API resources/methods are suffering the same problem as I have tested a subset of them only.