Skip to content

Error metadata not set on unmodeled errors #449

@aajtodd

Description

@aajtodd

Describe the bug

When an operation deserializer encounters an unmodeled error it throws a generic service exception (e.g. S3Exception rather than NoSuchBucketException) it does not populate sdkErrorMetadata

Expected Behavior

sdkErrorMetadata should be populated with protocol response, requestId, and other such metadata available from the response.

Current Behavior

All of the metadata is missing.

Steps to Reproduce

See #448 which demonstrates the issue and shows that in particular our documentation for debugging will not work:

    } catch (ex: AwsServiceException) {
        val httpResp = ex.sdkErrorMetadata.protocolResponse as? HttpResponse
        // Always null
        if (httpResp != null) {
            println(httpResp.headers)
            println(httpResp.body.readAll()?.decodeToString())
        }
        throw ex
    }

Possible Solution

private suspend fun throwListObjectsError(context: ExecutionContext, response: HttpResponse): kotlin.Nothing {
    ...

    val modeledExceptionDeserializer = when(errorDetails.code) {
        "NoSuchBucket" -> NoSuchBucketDeserializer()
        else -> throw S3Exception(errorDetails.message)   // this needs to also call `setS3ErrorMetadata` before being thrown
    }

    val modeledException = modeledExceptionDeserializer.deserialize(context, wrappedResponse)
    setS3ErrorMetadata(modeledException, wrappedResponse, errorDetails)
    throw modeledException
}

Context

Your Environment

  • AWS Kotlin SDK version used: 0.9.3-alpha
  • Platform (JVM/JS/Native): JVM
  • Operating System and version: MacOS 10.15.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions