ARTIFACTORY: How to resolve the “Could not download file from main zip resource” error when downloading a file within a VCS Tag

Elina Floim
2021-12-27 07:47

Artifactory supports the ability to list all the tags and branches of any VCS repository, proxy, and cache these tags and branches using Artifactory remote repositories. There are a few REST API endpoints that allow the download of a tag or branch. When attempting to download a file within a VCS tag via Artifactory, in some cases, a 404 response may be returned when requesting particular files. 

For this example, the swagger.json file from the kubernetes/kubernetes repository in Github is used:

$ curl -u<user>:<password> “http://<ART_HOST>/artifactory/api/vcs/downloadTagFile/<remote_repo>/kubernetes/kubernetes/v1.16.10!api/openapi-spec/swagger.json”
{
"errors" : [ {
"status" : 404,
"message" : "Could not download 'kubernetes-v1.16.10/api/openapi-spec/swagger.json' from main zip resource"
} ]
}

The request failed even though the requested file is present in this path. The same file can be requested via Github directly, using its API :

$ curl "https://api.github.com/repos/kubernetes/kubernetes/contents/api/openapi-spec/swagger.json?ref=v1.16.10"
{
"message": "This API returns blobs up to 1 MB in size. The requested blob is too large to fetch via the API, but you can use the Git Data API to request blobs up to 100 MB in size.",
"errors": [
{
"resource": "Blob",
"field": "data",
"code": "too_large"
}
],
"documentation_url": "https://docs.github.com/rest/reference/repos#get-repository-content"
}

According to Github's response, the API is limited to files that are less than 1MB in size. As a result, this request for the 5.7MB swagger.json file fails.

 

When attempting to resolve the file via Artifactory, the following warning will be printed in the logs:

2021-11-18T12:34:43.621Z [jfrt ] [WARN ] [745701dcc02f4ea2] [o.a.a.v.r.VcsRemoteHandler:407] [http-nio-8081-exec-5] – Resource driven lookup has failed (Not Found), trying repository.zip approach…

This means that the file resolution failed, and Artifactory is attempting to cache the branch as an archive file. This will be possible if the archive search feature is enabled. To enable it, navigate to the UI → Administration → Artifactory → General → Settings → Archive search enabled. This checkbox is available from Artifactory 7.15.3 and is disabled by default from this version onwards (archive search is enabled by default on versions lower than 7.15.3). 

When it’s enabled, the cached zip file can be found in the remote-cache repository:

User-added image