Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Search API Unable to Retrieve Assets by SHA256 Digest #550

Open
nida-hasan opened this issue Jan 14, 2025 · 0 comments
Open

Search API Unable to Retrieve Assets by SHA256 Digest #550

nida-hasan opened this issue Jan 14, 2025 · 0 comments
Assignees
Labels

Comments

@nida-hasan
Copy link

nida-hasan commented Jan 14, 2025

What problem are you trying to solve?

I am evaluating the OSS version of Nexus Repository Manager to determine its suitability for automating workflows. One requirement is the ability to search assets by their SHA256 digest. However, the /service/rest/v1/search/assets API returns an empty result when queried with a valid digest, even though the asset is visible in the response from /service/rest/v1/assets.

Do you have a workaround you are using at present?

I'm using /service/rest/repository/browse to manually locate the blob by iterating through all assets, but this is not scalable for automation

What feature or behavior is this required for?

I need to programmatically search blobs by their digest for automating workflows

Tell us about your Nexus Repository deployment: what version, operating system, and database are you using?

Nexus RepositoryOSS 3.75.1-01

Anything else?

Steps to reproduce this issue:

  1. Verify Asset Exists: Query the /service/rest/v1/assets API to confirm the asset exists:
    GET /service/rest/v1/assets?repository=alpine

    Json Response
    {
        "items": [{
                "downloadUrl": "http://localhost:8081/repository/alpine/v2/-/blobs/sha256:52f827f723504aa3325bb5a54247f0dc4b92bb72569525bc951532c4ef679bd4",
                "path": "/v2/-/blobs/sha256:52f827f723504aa3325bb5a54247f0dc4b92bb72569525bc951532c4ef679bd4",
                "id": "YWxwaW5lOjhmZjM0Nzhh",
                "repository": "alpine",
                "format": "docker",
                "checksum": {
                    "sha256": "52f827f723504aa3325bb5a54247f0dc4b92bb72569525bc951532c4ef679bd4",
                    "sha1": "65608834df7f0af4f23c7b8ea1299746b0843265"
                },
                "contentType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
                "lastModified": "2025-01-14T15:10:04.582+00:00",
                "lastDownloaded": "2025-01-14T15:11:01.154+00:00",
                "uploader": "admin",
                "uploaderIp": "172.17.0.1",
                "fileSize": 3992359,
                "blobCreated": "2025-01-14T15:10:04.598+00:00",
                "blobStoreName": null,
                "docker": {}
            },
            {
                "downloadUrl": "http://localhost:8081/repository/alpine/v2/-/blobs/sha256:7ad00e65ee25911881c06b97a3e562675d255e1265ba4abadd3e906d266c1dcc",
                "path": "/v2/-/blobs/sha256:7ad00e65ee25911881c06b97a3e562675d255e1265ba4abadd3e906d266c1dcc",
                "id": "YWxwaW5lOmRmMGYwNDY3",
                "repository": "alpine",
                "format": "docker",
                "checksum": {
                    "sha256": "7ad00e65ee25911881c06b97a3e562675d255e1265ba4abadd3e906d266c1dcc",
                    "sha1": "5c2196cd90d8fa552077d6fa416cf3e9ec4e49cc"
                },
                "contentType": "application/vnd.docker.container.image.v1+json",
                "lastModified": "2025-01-14T15:10:04.749+00:00",
                "lastDownloaded": "2025-01-14T15:10:04.772+00:00",
                "uploader": "admin",
                "uploaderIp": "172.17.0.1",
                "fileSize": 597,
                "blobCreated": "2025-01-14T15:10:04.752+00:00",
                "blobStoreName": null,
                "docker": {}
            },
            {
                "downloadUrl": "http://localhost:8081/repository/alpine/v2/alpine/alpine/manifests/sha256:e109f16fa790ab35054c49d1b7f2a83e7766daa1a8491a1e07998fa180952451",
                "path": "/v2/alpine/alpine/manifests/sha256:e109f16fa790ab35054c49d1b7f2a83e7766daa1a8491a1e07998fa180952451",
                "id": "YWxwaW5lOjJlMmFjMTQ0",
                "repository": "alpine",
                "format": "docker",
                "checksum": {
                    "sha256": "e109f16fa790ab35054c49d1b7f2a83e7766daa1a8491a1e07998fa180952451",
                    "sha1": "e241c28861c063e3e172fdcd19a4687be11f4757"
                },
                "contentType": "application/vnd.docker.distribution.manifest.v2+json",
                "lastModified": "2025-01-14T15:10:04.814+00:00",
                "lastDownloaded": "2025-01-14T15:11:13.240+00:00",
                "uploader": "admin",
                "uploaderIp": "172.17.0.1",
                "fileSize": 527,
                "blobCreated": "2025-01-14T15:10:04.819+00:00",
                "blobStoreName": null,
                "docker": {}
            },
            {
                "downloadUrl": "http://localhost:8081/repository/alpine/v2/alpine/alpine/manifests/latest",
                "path": "/v2/alpine/alpine/manifests/latest",
                "id": "YWxwaW5lOjdkNDY3ZTIx",
                "repository": "alpine",
                "format": "docker",
                "checksum": {
                    "sha256": "e109f16fa790ab35054c49d1b7f2a83e7766daa1a8491a1e07998fa180952451",
                    "sha1": "e241c28861c063e3e172fdcd19a4687be11f4757"
                },
                "contentType": "application/vnd.docker.distribution.manifest.v2+json",
                "lastModified": "2025-01-14T15:10:04.919+00:00",
                "lastDownloaded": null,
                "uploader": "admin",
                "uploaderIp": "172.17.0.1",
                "fileSize": 527,
                "blobCreated": "2025-01-14T15:10:04.931+00:00",
                "blobStoreName": null,
                "docker": {}
            }
        ],
        "continuationToken": null
    }
  2. Search for the Asset by Digest: Query the /service/rest/v1/search/assets API with the asset's SHA256:
    GET /service/rest/v1/search/assets?repository=alpine&sha256=7ad00e65ee25911881c06b97a3e562675d255e1265ba4abadd3e906d266c1dcc

    OR

    GET /service/rest/v1/search/assets?repository=alpine&docker.contentDigest=sha256:7ad00e65ee25911881c06b97a3e562675d255e1265ba4abadd3e906d266c1dcc

    returns:

        {
            "items": [],
            "continuationToken": null
        }

I am not sure if I am using the API incorrectly or if I should be using a different parameter to search. Any assistance would be appreciated. Thank you!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants