Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(images): distinguish missing upload objects (#7817)
r33drichards1cbca720360a
diff --git a/libs/fleet/backend/handlers/image_uploads.go b/libs/fleet/backend/handlers/image_uploads.goindex bf654b910a..80da7605ab 100644--- a/libs/fleet/backend/handlers/image_uploads.go+++ b/libs/fleet/backend/handlers/image_uploads.go@@ -237,6 +237,24 @@ func (s *s3ImageObjectStore) Exists(ctx context.Context, key string, size int64,if err != nil {return false, err}+ objects, err := s.client.ListObjectsV2(ctx, &s3.ListObjectsV2Input{+ Bucket: aws.String(s.bucket),+ Prefix: aws.String(key),+ MaxKeys: aws.Int32(1),+ })+ if err != nil {+ return false, err+ }+ found := false+ for _, candidate := range objects.Contents {+ if aws.ToString(candidate.Key) == key {+ found = true+ break+ }+ }+ if !found {+ return false, nil+ }object, err := s.client.HeadObject(ctx, &s3.HeadObjectInput{Bucket: aws.String(s.bucket),Key: aws.String(key),diff --git a/libs/fleet/backend/handlers/image_uploads_test.go b/libs/fleet/backend/handlers/image_uploads_test.goindex ec81902d07..b92eb4f08c 100644--- a/libs/fleet/backend/handlers/image_uploads_test.go+++ b/libs/fleet/backend/handlers/image_uploads_test.go@@ -367,7 +367,14 @@ func TestS3ImageObjectStoreExistsRequiresExactSizeAndChecksum(t *testing.T) {for _, test := range tests {t.Run(test.name, func(t *testing.T) {var checksumMode string+ var requests []stringstore := testS3ImageObjectStore(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if r.Method == http.MethodGet && r.URL.Query().Get("list-type") == "2" {+ requests = append(requests, "list")+ fmt.Fprint(w, `<?xml version="1.0" encoding="UTF-8"?><ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>image-uploads</Name><Prefix>tenants/workers/images/test</Prefix><KeyCount>1</KeyCount><MaxKeys>1</MaxKeys><IsTruncated>false</IsTruncated><Contents><Key>tenants/workers/images/test</Key><Size>12</Size></Contents></ListBucketResult>`)+ return+ }+ requests = append(requests, "head")checksumMode = r.Header.Get("X-Amz-Checksum-Mode")w.Header().Set("Content-Length", fmt.Sprint(test.size))if test.checksum != "" {@@ -386,10 +393,36 @@ func TestS3ImageObjectStoreExistsRequiresExactSizeAndChecksum(t *testing.T) {if got, want := checksumMode, "ENABLED"; got != want {t.Fatalf("checksum mode = %q, want %q", got, want)}+ if got, want := strings.Join(requests, ","), "list,head"; got != want {+ t.Fatalf("requests = %q, want %q", got, want)+ }})}}+func TestS3ImageObjectStoreExistsReturnsFalseFromEmptyExactPrefixList(t *testing.T) {+ var requests int+ store := testS3ImageObjectStore(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ requests+++ if r.Method != http.MethodGet || r.URL.Query().Get("list-type") != "2" ||+ r.URL.Query().Get("prefix") != "tenants/workers/images/test" || r.URL.Query().Get("max-keys") != "1" {+ t.Fatalf("unexpected request: %s %s", r.Method, r.URL.String())+ }+ fmt.Fprint(w, `<?xml version="1.0" encoding="UTF-8"?><ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>image-uploads</Name><Prefix>tenants/workers/images/test</Prefix><KeyCount>0</KeyCount><MaxKeys>1</MaxKeys><IsTruncated>false</IsTruncated></ListBucketResult>`)+ }))++ exists, err := store.Exists(context.Background(), "tenants/workers/images/test", 12, imageUploadDigest)+ if err != nil {+ t.Fatalf("Exists() error = %v", err)+ }+ if exists {+ t.Fatal("Exists() = true, want false")+ }+ if requests != 1 {+ t.Fatalf("requests = %d, want 1", requests)+ }+}+func testS3ImageObjectStore(t *testing.T, handler http.Handler) ImageObjectStore {t.Helper()server := httptest.NewServer(handler)