How to find out what i'm doing wrong. Getting validation exception in timestream write Records with go sdk?

898 Views Asked by At

As the title says, I'm trying to write a bunch of records to timestream, but I keep getting "ValidationException" without any further information, so I have no idea what should be fixed. The exact error response is:

operation error Timestream Write: WriteRecords, https response error StatusCode: 400, RequestID: XXXXXXXXXXXXXX, ValidationException:

It made me think that it was a multiline string and somehow the logging framework wasn't logging properly, but I tried splitting by \n and all I got was a size 1 list with the same text.

Any ideas?

1

There are 1 best solutions below

0
On

For some reason, the validation error is wrapped multiple errors deep. To get to the validation error message, you need the following:

import (
    "fmt"
    "github.com/aws/aws-sdk-go-v2/aws"
    "github.com/aws/aws-sdk-go-v2/aws/transport/http"
    "github.com/aws/aws-sdk-go-v2/service/timestreamwrite/types"
    "github.com/aws/smithy-go"
)
responseError := err.(*smithy.OperationError).Unwrap().(*http.ResponseError)
validationError := responseError.Unwrap().(*types.ValidationException)
fmt.Println(validationError.ErrorMessage())