aws / smithy-go

Smithy code generators for Go (in development)
Apache License 2.0
172 stars 51 forks source link

Trouble with NewLazyDocument and map[string]interface{} #532

Closed mgomes closed 1 month ago

mgomes commented 1 month ago

Here is a minimally reproducible example of the issue I am running into:

package main

import (
    "fmt"
    "log"

    "github.com/aws/aws-sdk-go-v2/service/bedrockruntime/document"
)

func main() {
    doc := document.NewLazyDocument(map[string]interface{}{
        "param1": "value1",
    })

    var result map[string]interface{}
    err := doc.UnmarshalSmithyDocument(&result)
    if err != nil {
        log.Fatalf("Error unmarshalling Smithy document: %v", err)
    }

    fmt.Printf("Unmarshalled result: %+v\n", result)
}

Running this code produces the error: Error unmarshalling Smithy document: unsupported json type, *map[string]interface {}

Is NewLazyDocument storing the map as a pointer internally somehow and so it isn't getting recognized? It seems like it should work when looking at the decoder: https://github.com/aws/smithy-go/blob/main/document/json/decoder.go#L71.

mgomes commented 1 month ago

Closing this, I opened up the issue in the aws-sdk instead: https://github.com/aws/aws-sdk-go-v2/issues/2751