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

Could not parse XML response when getObjectAttributes #4136

Closed
evil0th opened this issue Jun 27, 2023 · 3 comments
Closed

Could not parse XML response when getObjectAttributes #4136

evil0th opened this issue Jun 27, 2023 · 3 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@evil0th
Copy link

evil0th commented Jun 27, 2023

Describe the bug

I have several two S3 buckets where data is written to the buckets . when I run into an issue where get the object attributes causes an exceptIon:

software.amazon.awssdk.core.exception.SdkClientException: Could not parse XML response.

	at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:111)
	at software.amazon.awssdk.core.exception.SdkClientException.create(SdkClientException.java:47)
	at software.amazon.awssdk.protocols.query.unmarshall.XmlDomParser.parse(XmlDomParser.java:59)
	at software.amazon.awssdk.protocols.xml.internal.unmarshall.XmlResponseParserUtils.parse(XmlResponseParserUtils.java:64)
	at software.amazon.awssdk.protocols.xml.internal.unmarshall.AwsXmlPredicatedResponseHandler.parseResponse(AwsXmlPredicatedResponseHandler.java:116)
	at software.amazon.awssdk.protocols.xml.internal.unmarshall.AwsXmlPredicatedResponseHandler.handleResponse(AwsXmlPredicatedResponseHandler.java:96)
	at software.amazon.awssdk.protocols.xml.internal.unmarshall.AwsXmlPredicatedResponseHandler.handle(AwsXmlPredicatedResponseHandler.java:85)
	at software.amazon.awssdk.protocols.xml.internal.unmarshall.AwsXmlPredicatedResponseHandler.handle(AwsXmlPredicatedResponseHandler.java:43)
	at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler$Crc32ValidationResponseHandler.handle(AwsSyncClientHandler.java:95)
	at software.amazon.awssdk.core.internal.handler.BaseClientHandler.lambda$successTransformationResponseHandler$7(BaseClientHandler.java:270)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.HandleResponseStage.execute(HandleResponseStage.java:40)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.HandleResponseStage.execute(HandleResponseStage.java:30)
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptTimeoutTrackingStage.execute(ApiCallAttemptTimeoutTrackingStage.java:72)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptTimeoutTrackingStage.execute(ApiCallAttemptTimeoutTrackingStage.java:42)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.TimeoutExceptionHandlingStage.execute(TimeoutExceptionHandlingStage.java:78)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.TimeoutExceptionHandlingStage.execute(TimeoutExceptionHandlingStage.java:40)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptMetricCollectionStage.execute(ApiCallAttemptMetricCollectionStage.java:52)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptMetricCollectionStage.execute(ApiCallAttemptMetricCollectionStage.java:37)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:81)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:36)
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
	at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:56)
	at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:36)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.executeWithTimer(ApiCallTimeoutTrackingStage.java:80)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.execute(ApiCallTimeoutTrackingStage.java:60)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.execute(ApiCallTimeoutTrackingStage.java:42)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallMetricCollectionStage.execute(ApiCallMetricCollectionStage.java:48)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallMetricCollectionStage.execute(ApiCallMetricCollectionStage.java:31)
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:37)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:26)
	at software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient$RequestExecutionBuilderImpl.execute(AmazonSyncHttpClient.java:193)
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.invoke(BaseSyncClientHandler.java:103)
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.doExecute(BaseSyncClientHandler.java:171)
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.lambda$execute$1(BaseSyncClientHandler.java:82)
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.measureApiCallSuccess(BaseSyncClientHandler.java:179)
	at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:76)
	at software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:45)
	at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:56)
	at software.amazon.awssdk.services.s3.DefaultS3Client.getObjectAttributes(DefaultS3Client.java:4795)
......
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: 前言中不允许有内容。
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:652)
	at java.xml/com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderImpl.java:83)
	at software.amazon.awssdk.protocols.query.unmarshall.XmlDomParser.parse(XmlDomParser.java:55)
	... 110 more

The block of code that causes this is as follows:

 client.getObjectAttributes(GetObjectAttributesRequest.builder()
			.bucket(bucket)
			.key(key)
			.objectAttributes(ObjectAttributes.E_TAG)
			.build());

Expected Behavior

retun object ETag attribute

Current Behavior

2023-06-27 10:22:12.318 DEBUG 57562 --- [           main] s.a.a.c.i.ExecutionInterceptorChain      : Creating an interceptor chain that will apply interceptors in the following order: [software.amazon.awssdk.core.internal.interceptor.HttpChecksumRequiredInterceptor@e0d1dc4, software.amazon.awssdk.core.internal.interceptor.SyncHttpChecksumInTrailerInterceptor@5463f035, software.amazon.awssdk.core.internal.interceptor.HttpChecksumValidationInterceptor@230232b0, software.amazon.awssdk.core.internal.interceptor.AsyncRequestBodyHttpChecksumTrailerInterceptor@44fd7ba4, software.amazon.awssdk.core.internal.interceptor.HttpChecksumInHeaderInterceptor@22f8adc2, software.amazon.awssdk.awscore.interceptor.HelpfulUnknownHostExceptionInterceptor@69d103f0, software.amazon.awssdk.awscore.eventstream.EventStreamInitialRequestInterceptor@5b742bc8, software.amazon.awssdk.awscore.interceptor.TraceIdExecutionInterceptor@74fb5b59, software.amazon.awssdk.services.s3.endpoints.internal.S3ResolveEndpointInterceptor@130a6eb9, software.amazon.awssdk.services.s3.endpoints.internal.S3EndpointAuthSchemeInterceptor@722531ab, software.amazon.awssdk.services.s3.endpoints.internal.S3RequestSetEndpointInterceptor@8f57e4c, software.amazon.awssdk.services.s3.internal.handlers.PutObjectInterceptor@26fadd98, software.amazon.awssdk.services.s3.internal.handlers.CreateBucketInterceptor@66451058, software.amazon.awssdk.services.s3.internal.handlers.CreateMultipartUploadRequestInterceptor@3db6dd52, software.amazon.awssdk.services.s3.internal.handlers.EnableChunkedEncodingInterceptor@1e92c3b6, software.amazon.awssdk.services.s3.internal.handlers.ConfigureSignerInterceptor@6ef4cbe1, software.amazon.awssdk.services.s3.internal.handlers.DecodeUrlEncodedResponseInterceptor@207dd1b7, software.amazon.awssdk.services.s3.internal.handlers.GetBucketPolicyInterceptor@2baac4a7, software.amazon.awssdk.services.s3.internal.handlers.AsyncChecksumValidationInterceptor@23ad2d17, software.amazon.awssdk.services.s3.internal.handlers.SyncChecksumValidationInterceptor@6bce4140, software.amazon.awssdk.services.s3.internal.handlers.EnableTrailingChecksumInterceptor@25f0c5e7, software.amazon.awssdk.services.s3.internal.handlers.ExceptionTranslationInterceptor@5882b202, software.amazon.awssdk.services.s3.internal.handlers.GetObjectInterceptor@120df990, software.amazon.awssdk.services.s3.internal.handlers.CopySourceInterceptor@b506ed0, software.amazon.awssdk.transfer.s3.internal.ApplyUserAgentInterceptor@282c4da0]
2023-06-27 10:22:12.382 DEBUG 57562 --- [           main] s.a.a.c.i.ExecutionInterceptorChain      : Interceptor 'software.amazon.awssdk.services.s3.endpoints.internal.S3EndpointAuthSchemeInterceptor@722531ab' modified the message with its modifyRequest method.
2023-06-27 10:22:12.383 TRACE 57562 --- [           main] s.a.a.c.i.ExecutionInterceptorChain      : Old: GetObjectAttributesRequest(Bucket=images, Key=b.txt, ObjectAttributes=[ObjectSize])
New: GetObjectAttributesRequest(Bucket=images, Key=b.txt, ObjectAttributes=[ObjectSize])
2023-06-27 10:22:12.383 DEBUG 57562 --- [           main] s.a.a.c.i.ExecutionInterceptorChain      : Interceptor 'software.amazon.awssdk.transfer.s3.internal.ApplyUserAgentInterceptor@282c4da0' modified the message with its modifyRequest method.
2023-06-27 10:22:12.384 TRACE 57562 --- [           main] s.a.a.c.i.ExecutionInterceptorChain      : Old: GetObjectAttributesRequest(Bucket=images, Key=b.txt, ObjectAttributes=[ObjectSize])
New: GetObjectAttributesRequest(Bucket=images, Key=b.txt, ObjectAttributes=[ObjectSize])
2023-06-27 10:22:12.413 DEBUG 57562 --- [           main] s.a.a.c.i.ExecutionInterceptorChain      : Interceptor 'software.amazon.awssdk.services.s3.endpoints.internal.S3RequestSetEndpointInterceptor@8f57e4c' modified the message with its modifyHttpRequest method.
2023-06-27 10:22:12.413 TRACE 57562 --- [           main] s.a.a.c.i.ExecutionInterceptorChain      : Old: DefaultSdkHttpFullRequest(httpMethod=GET, protocol=http, host=192.168.1.169, port=9000, encodedPath=/b.txt, headers=[x-amz-object-attributes], queryParameters=[attributes])
New: DefaultSdkHttpFullRequest(httpMethod=GET, protocol=http, host=192.168.1.169, port=9000, encodedPath=/images/b.txt, headers=[x-amz-object-attributes], queryParameters=[attributes])
2023-06-27 10:22:12.435 DEBUG 57562 --- [           main] software.amazon.awssdk.request           : Sending Request: DefaultSdkHttpFullRequest(httpMethod=GET, protocol=http, host=192.168.1.169, port=9000, encodedPath=/images/b.txt, headers=[amz-sdk-invocation-id, User-Agent, x-amz-object-attributes], queryParameters=[attributes])
2023-06-27 10:22:12.448 DEBUG 57562 --- [           main] s.amazon.awssdk.auth.signer.Aws4Signer   : AWS4 Canonical Request: GET
/images/b.txt
attributes=
amz-sdk-invocation-id:a6483aa0-23e5-8e2d-4587-af209f6b6fd1
amz-sdk-request:attempt=1; max=4
host:192.168.1.169:9000
x-amz-content-sha256:UNSIGNED-PAYLOAD
x-amz-date:20230627T022212Z
x-amz-object-attributes:ObjectSize

amz-sdk-invocation-id;amz-sdk-request;host;x-amz-content-sha256;x-amz-date;x-amz-object-attributes
UNSIGNED-PAYLOAD
2023-06-27 10:22:12.449 DEBUG 57562 --- [           main] s.amazon.awssdk.auth.signer.Aws4Signer   : AWS4 String to sign: AWS4-HMAC-SHA256
20230627T022212Z
20230627/cn-north-1/s3/aws4_request
c86900df6f8b8bcc9cb34c5a30301c0804839b23aa30180634fe7eab88f3b650
2023-06-27 10:22:12.449 TRACE 57562 --- [           main] s.amazon.awssdk.auth.signer.Aws4Signer   : Generating a new signing key as the signing key not available in the cache for the date: 1687832532439

Reproduction Steps

  1. upload any object
  2. java code example
// snippet-comment:[These are tags for the AWS doc team's sample catalog. Do not remove.]
// snippet-sourcedescription:[GetObjectContentType.java demonstrates how to determine the content type of an object in an Amazon Simple Storage Service (Amazon S3) bucket.]
//snippet-keyword:[AWS SDK for Java v2]
//snippet-service:[Amazon S3]

/*
   Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
   SPDX-License-Identifier: Apache-2.0
*/

package com.example.s3;

// snippet-start:[s3.java2.getobjectcontenttype.import]

import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.GetObjectAttributesRequest;
import software.amazon.awssdk.services.s3.model.GetObjectAttributesResponse;
import software.amazon.awssdk.services.s3.model.ObjectAttributes;
import software.amazon.awssdk.services.s3.model.S3Exception;
// snippet-end:[s3.java2.getobjectcontenttype.import]

/**
 * Before running this Java V2 code example, set up your development environment, including your credentials.
 * <p>
 * For more information, see the following documentation topic:
 * <p>
 * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
 */

public class GetObjectAttributes {

    public static void main(String[] args) {

        final String usage = "\n" +
                "Usage:\n" +
                "    <bucketName> <keyName>>\n\n" +
                "Where:\n" +
                "    bucketName - The Amazon S3 bucket name. \n\n" +
                "    keyName - The key name. \n\n";

        if (args.length != 2) {
            System.out.println(usage);
            System.exit(1);
        }

        String bucketName = args[0];
        String keyName = args[1];
        ProfileCredentialsProvider credentialsProvider = ProfileCredentialsProvider.create();
        Region region = Region.US_EAST_1;
        S3Client s3 = S3Client.builder()
                .region(region)
                .credentialsProvider(credentialsProvider)
                .build();

        getObjectAttributes(s3, bucketName, keyName);
        s3.close();
    }

    // snippet-start:[s3.java2.getobjectcontenttype.main]
    public static void getObjectAttributes(S3Client s3, String bucketName, String keyName) {

        try {
            final GetObjectAttributesRequest objectRequest = GetObjectAttributesRequest.builder()
                    .bucket(bucketName)
                    .key(keyName)
                    .objectAttributes(ObjectAttributes.E_TAG)
                    .build();

            GetObjectAttributesResponse response = s3.getObjectAttributes(objectRequest);
            String responseString = response.toString();
            System.out.println("The object attributes response is " + responseString);
        } catch (S3Exception e) {
            System.err.println(e.awsErrorDetails().errorMessage());
            System.exit(1);
        }
    }
    // snippet-end:[s3.java2.getobjectcontenttype.main]
}

Possible Solution

have no idea

Additional Information/Context

Minio version 2023-06-23T20:36:00Z and Aliyun OSS

AWS Java SDK version used

2.20.92

JDK version used

java version "11.0.18" 2023-01-17 LTS

Operating System and version

MacOS Ventura 13.5 / Ubuntu 23.04

@evil0th evil0th added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 27, 2023
@evil0th evil0th closed this as completed Jun 27, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@evil0th evil0th closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@wcmatthysen
Copy link

wcmatthysen commented Jan 25, 2024

I've also run into this issue. It seems as though MinIO hasn't implemented the get-object-attributes functionality yet (this is also mentioned here) . Rather use HeadObjectRequest to retrieve the e-tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants