Nexus 3 inconsistent api results

Hi
item found using search api but can’t be deleted or read ( returns 404) when using assets api.
our asset is a raw asset
Sometime it does work, but mostly it doesnt.

see below - query the same asset 3 times with no quote, double quote and single quote - all returning 404.

curl -u ‘…’ -X GET http://XXXX:8081/sevice/rest/v1/assets/dG1vX3JlcG9zaXRvcnlfaGVsbTphMmEzMGRmODIxMTUyMDU2ZDQ3YzU0MzI2NjMzN2E5NA
curl: (22) The requested URL returned error: 404 Not Found
[tmoapp1@incetmo017 yaml]$
curl -u ‘…’ -X GET “http://XXX:8081/sevice/rest/v1/assets/dG1vX3JlcG9zaXRvcnlfaGVsbTphMmEzMGRmODIxMTUyMDU2ZDQ3YzU0MzI2NjMzN2E5NA
curl: (22) The requested URL returned error: 404 Not Found

curl -u ‘…’ -X GET ‘http://XXX:8081/sevice/rest/v1/assets/dG1vX3JlcG9zaXRvcnlfaGVsbTphMmEzMGRmODIxMTUyMDU2ZDQ3YzU0MzI2NjMzN2E5NA
curl: (22) The requested URL returned error: 404 Not Found

now with search/asset is there with exact same ID

curl -v -u … -X GET http://XXX:8081/service/rest/v1/search/assets?name=price-managementhook/price-managementhook-2012.12.1-3.tgz

GET /service/rest/v1/search/assets?name=price-managementhook/price-managementhook-2012.12.1-3.tgz HTTP/1.1
Authorization: Basic ZG9ja2VycHVzaDpkb2NrZXJwdXNo
User-Agent: curl/7.29.0
Host: XXX
Accept: /

< HTTP/1.1 200 OK
< Server: Nexus/3.25.1-04 (OSS)
<
{
“items” : [ {
“downloadUrl” : “http://XXX:8081/repository/XXX/price-managementhook/price-managementhook-2012.12.1-3.tgz”,
“path” : “price-managementhook/price-managementhook-2012.12.1-3.tgz”,
“id” : “dG1vX3JlcG9zaXRvcnlfaGVsbTphMmEzMGRmODIxMTUyMDU2ZDQ3YzU0MzI2NjMzN2E5NA”,
“repository” : “XXX_repository_helm”,
“format” : “raw”,
“checksum” : {
“sha1” : “5b9153acf7f03ca30bf9211c820ef59e485f00ff”,
“md5” : “e29b0c5bc686405c6439324c85ec758d”
}
} ],
“continuationToken” : null

Any idea how we can have consistent results when we need to programmatically delete raw assets from Nexus

thanks

Ori

Hi Ori Keren,

You are getting 404 Not Found response when trying to get or delete an asset, because that asset does not exists in your repository. However, you keep seeing the asset in your search results, because your search index might be out of date. Please run “Repair - Rebuild repository search” task and try again to search again after the task completes. Here’s documentation page for the tasks: Tasks
We are continuously improving the product and fixing any reported bugs, so please upgrade to the latest version to ensure you are using the latest and greatest version of our products.

thanks Dawid for answering

I will ask the nexus owner to repair the indexes , still , can it be that I can see the same artifact in the UI, but still have a 404 when trying to delete it using the api?
For the above example - I can see price-managementhook/price-managementhook-2012.12.1-3.tgz in the UI and download it without problems, meaning that the artifact is there.

regards
Ori

If you have a paid licence you can open a support ticket, so we can take a look at what’s happening on your Repository instance.

I will check with our IT team about licensing

today I saw a similar case which ended with a 405 error, the search API worked ok and returned the ID, the object is also visible in UI.

Can you share why 405 is thrown here ?
“path” : “account-financialaccounthook/account-financialaccounthook-2109.1310.4.tgz”,
“id” : “dG1vX3JlcG9zaXRvcnlfaGVsbTo4ZGEzZDMyOGZiYmExNjUwMTBiMjRjYjI0OTNkMDAwZQ”,

curl -u ‘…’ -X DELETE -k http://XXXX:8081/sevice/rest/v1/assets/dG1vX3JlcG9zaXRvcnlfaGVsbTo4ZGEzZDMyOGZiYmExNjUwMTBiMjRjYjI0OTNkMDAwZQ
curl: (22) The requested URL returned error: 405 Http method DELETE is not supported by this URL

I don’t believe that NXRM will throw a 405 based on the url you are showing and what the REST API says. It’s possible you are getting blocked by a proxy server (ie nginx). Check the sonatype-work/nexus3/log/request.log to ensure that your request is actually reaching the nexus instance. If it is you’ll want to see if there are any strange errors in the nexus.log.

Hi
There is no proxy present between the two machines, the search api as well as deletion of docker images and even certain Delete assets (few) calls do pass without problem, majority of the delete assets call that I generated in script (first run search, next build the delete assets call based on the ID from the first call) are failing either on 404 or 405 errors.
I will ask to check the nexus log next week.

Hi
we checked Nexus request logs - the requests are there, we also checked the general nexus.log - nothing is showing in the case of 405 error
I also tried to use the GET asset API for the same ID which I received using the search API, this is resulting in 404 error (not found)
last thing we did was to run the ‘re-index’ task , results are the same.

as for licensing, unfortunately we dont have a support license

regards

Ori

the 405 issue is now resolved - there was a typo in the URL
issue resolved

1 Like