Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Field "Type" Missing when pushing build with Docker image #202

Open
Erwan-loot opened this issue Oct 23, 2024 · 0 comments
Open

Field "Type" Missing when pushing build with Docker image #202

Erwan-loot opened this issue Oct 23, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Erwan-loot
Copy link

Erwan-loot commented Oct 23, 2024

Describe the bug
When trying to retrieve build information using pyartifactory, an error occurs due to a missing type field in the Docker image layers within the artifacts. Specifically, some Docker layers do not have a type field, and this causes a Pydantic validation error when attempting to parse the response into the BuildInfo model.

To Reproduce
Originally, the bug was encountered while trying to promote a Docker image using art.builds.promote_build(build_name, build_number, build_promote_request).
Due to this issue, I decided to test with a simpler request to retrieve build information using art.builds.get_build_info(build_name, build_number)
Steps to reproduce the behavior:

  1. Pull and push an image to artifactory using jfrog cli
docker pull nginx

docker tag nginx:latest <URL of repository>/nginx:1.0.0

 jfrog docker push <URL of repository>/nginx:1.0.0 --build-name=nginx --build-number=1.0.0

 jfrog rt build-publish nginx 1.0.0

We can see the build in the UI
image

  1. Attempt to retrieve build information using art.builds.get_build_info(build_name, build_number) where build_name and build_number point to a Docker image that has layers without a type field.
art.builds.get_build_info("nginx","1.0.0")
  1. See the following error:
9 validation errors for BuildInfo buildInfo.modules.0.artifacts.1.type Field required For further information visit https://errors.pydantic.dev/2.9/v/missing

Here the content of the json of the build

{
    "version": "1.0.1",
    "name": "nginx",
    "number": "1.0.0",
    "buildAgent": {
        "name": "GENERIC",
        "version": "2.71.0"
    },
    "agent": {
        "name": "jfrog-cli-go",
        "version": "2.71.0"
    },
    "started": "2024-10-23T16:13:07.424+0200",
    "durationMillis": 0,
    "artifactoryPrincipal": "ME",
    "modules": [
        {
            "properties": {
                "docker.image.tag": "URL of repository/nginx:1.0.0",
                "docker.image.id": "sha256:3b25b682ea82b2db3cc4fd48db818be788ee3f902ac7378090cf2624ec2442df"
            },
            "type": "docker",
            "id": "nginx:1.0.0",
            "artifacts": [
                {
                    "type": "json",
                    "sha1": "4a83ccb46d23b375d9ea1dc3cb4596d70882a6bd",
                    "sha256": "7ba542bde95e6523a4b126f610553e3657b8108bc3175596ee7e911ae1219bfc",
                    "md5": "6584996e9f4f8a46a43e17882d73a504",
                    "name": "manifest.json",
                    "path": "nginx/1.0.0/manifest.json"
                },
                {
                    "sha1": "20d3027559175e5cc56ca1b5623db475ee4bbf3c",
                    "sha256": "3b25b682ea82b2db3cc4fd48db818be788ee3f902ac7378090cf2624ec2442df",
                    "md5": "39ea5d62d340dcc4b3520744d83562bc",
                    "name": "sha256__3b25b682ea82b2db3cc4fd48db818be788ee3f902ac7378090cf2624ec2442df",
                    "path": "nginx/1.0.0/sha256__3b25b682ea82b2db3cc4fd48db818be788ee3f902ac7378090cf2624ec2442df"
                },

As you can see only the manifest has a TYPE filed.
Expected behavior
The retrieval of build information should handle artifacts that do not have a type field gracefully. The type field should be treated as optional, and the absence of this field should not cause the operation to fail.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment:

  • Ubuntu 24.04
  • pyartifactory version 2.7.1:
  • Python 3.12.3:

Additional context
This issue can be reproduced consistently with Docker image artifacts, as not all image layers have a type field in their metadata. It appears that the BuildArtifact model in pyartifactory expects this field, causing validation errors when it is missing.

@Erwan-loot Erwan-loot added the bug Something isn't working label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant