{"record":{"id":"c6a17e17a5b1f535","repo":"dgraph-io/dgraph","slug":"failed-to-read-s3-object","errorCode":null,"errorMessage":"Failed to read s3 object","messagePattern":"Failed to read s3 object","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/backup_handler.go","lineNumber":311,"sourceCode":"\t}\n\terrResponse := minio.ToErrorResponse(err)\n\tif errResponse.Code != \"NoSuchKey\" {\n\t\tglog.Errorf(\"Failed to verify object existence: %v\", err)\n\t}\n\treturn false\n}\n\nfunc (h *s3Handler) JoinPath(path string) string {\n\treturn filepath.Join(h.bucketName, h.objectPrefix, cleanRelPath(path))\n}\n\nfunc (h *s3Handler) Read(path string) ([]byte, error) {\n\tobjectPath := h.getObjectPath(path)\n\tvar buf bytes.Buffer\n\n\treader, err := h.mc.GetObject(context.Background(), h.bucketName, objectPath, minio.GetObjectOptions{})\n\tif err != nil {\n\t\treturn buf.Bytes(), errors.Wrap(err, \"Failed to read s3 object\")\n\t}\n\tdefer reader.Close()\n\n\tif _, err := buf.ReadFrom(reader); err != nil {\n\t\treturn buf.Bytes(), errors.Wrap(err, \"Failed to read the s3 object\")\n\t}\n\treturn buf.Bytes(), nil\n}\n\nfunc (h *s3Handler) Stream(path string) (io.ReadCloser, error) {\n\tobjectPath := h.getObjectPath(path)\n\treader, err := h.mc.GetObject(context.Background(), h.bucketName, objectPath, minio.GetObjectOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn reader, nil\n}\n","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/backup_handler.go#L293-L329","documentation":"s3Handler.Read wraps minio.GetObject client-side failures with 'Failed to read s3 object'. This fires when obtaining the object reader itself fails (client/config error); errors during streaming the body produce the sibling 'Failed to read the s3 object' message instead.","triggerScenarios":"minio.GetObject returns an error before any read: invalid bucket/object path, bad credentials/endpoint configuration, network failure to the S3 endpoint, or wrong-region bucket — while calling s3Handler.Read.","commonSituations":"Wrong minio endpoint or TLS config; deleted or non-existent backup object; IAM/key revoked; DNS/network outage to the S3 endpoint; object name mismatch due to prefix misconfiguration.","solutions":["Check the wrapped cause for minio's error type (BucketDoesNotExist, ObjectDoesNotExist, auth, connection).","Verify credentials (access/secret, session token) and endpoint/TLS settings.","Confirm the object exists: mc ls / head-object on bucket+objectPath (check objectPrefix).","Test network reachability to the endpoint (curl/DNS) and correct region/virtual-host settings.","Re-run the operation once connectivity/auth is fixed — reads are safe to retry."],"exampleFix":"// before\nreader, err := h.mc.GetObject(ctx, h.bucketName, objectPath, minio.GetObjectOptions{})\nif err != nil {\n    return buf.Bytes(), errors.Wrap(err, \"Failed to read s3 object\")\n}\n// after\nreader, err := h.mc.GetObject(ctx, h.bucketName, objectPath, minio.GetObjectOptions{})\nif err != nil {\n    resp := minio.ToErrorResponse(err)\n    return buf.Bytes(), errors.Wrapf(err, \"Failed to read s3 object (code=%s)\", resp.Code)\n}","handlingStrategy":"retry","validationCode":"ok, err := h.mc.BucketExists(ctx, h.bucketName)\nif err != nil || !ok {\n    return fmt.Errorf(\"bucket %s unreachable or missing: %v\", h.bucketName, err)\n}\nif _, err := h.mc.StatObject(ctx, h.bucketName, h.getObjectPath(path), minio.StatObjectOptions{}); err != nil {\n    return fmt.Errorf(\"object %s missing: %v\", path, err)\n}","typeGuard":null,"tryCatchPattern":"data, err := handler.Read(p)\nif err != nil {\n    if strings.Contains(err.Error(), \"Failed to read s3 object\") {\n        return retryWithBackoff(3, func() error { _, e := handler.Read(p); return e })\n    }\n    return err\n}","preventionTips":["Validate S3 credentials and bucket existence at startup.","Log resolved object paths (prefix + path) to catch prefix misconfig.","Use short retry with backoff for transient network errors.","Keep lifecycle rules from deleting active backup objects."],"tags":["s3","minio","network"],"backgroundTag":"s3-object-not-found","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}