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

[Bug] Client::pull_blob returns Ok(...) even when the blob wasn't found #64

Open
aochagavia opened this issue Feb 7, 2023 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@aochagavia
Copy link
Contributor

Steps to reproduce

The following test reproduces the issue (you can paste it under client::test and run it with cargo test --features test-registry test_pull_blob_not_found):

#[tokio::test]
#[cfg(feature = "test-registry")]
async fn test_pull_blob_not_found() {
    // initialize the registry
    let docker = clients::Cli::default();
    let test_container = docker.run(registry_image());
    let port = test_container.get_host_port_ipv4(5000);

    let c = Client::new(ClientConfig {
        protocol: ClientProtocol::HttpsExcept(vec![format!("localhost:{}", port)]),
        ..Default::default()
    });

    // Layer is not found at `image-repository`
    let image_reference: Reference = format!("localhost:{}/image-repository", port).parse().unwrap();
    let mut buf = Vec::new();
    let dummy_digest = sha256_digest(&[]);
    let pull_result = c.pull_blob(&image_reference, &dummy_digest, &mut buf).await;

    // The result is OK, but the response body does not correspond to the contents of the blob
    assert!(pull_result.is_ok());
    assert!(String::from_utf8(buf).unwrap().starts_with("{\"errors\":[{\"code\":\"BLOB_UNKNOWN\""));
}

Expected result

As a user of the library, I intuitively expect pull_blob to return Ok only when the blob was found, and Err otherwise.

@thomastaylor312 thomastaylor312 added bug Something isn't working help wanted Extra attention is needed labels Feb 28, 2023
@thomastaylor312
Copy link
Contributor

Sorry for the delay here. Was swamped with GH notifications. This is definitely a bug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants