watson-developer-cloud / go-sdk

:mouse: go SDK for the IBM Watson services.
Apache License 2.0
71 stars 25 forks source link

List Logs doesn't work properly #60

Closed RoloGH closed 4 years ago

RoloGH commented 4 years ago

[ListLogs] Fetching logs fails.

Overview:

When trying to fetch logs using the fetch logs method of the SDK, the operation fails due to errors in the types.

Expected Behavior:

Return a list of Watson conversation logs as a json

Actual Behavior:

Received a different list of panics and errors:

panic: interface conversion: interface {} is string, not *string
github.com/watson-developer-cloud/go-sdk/assistantv1.(*Context).GetConversationID(...)
panic: interface conversion: interface {} is []interface {}, not *[]string
github.com/watson-developer-cloud/go-sdk/assistantv1.(*OutputData).GetText(...)
panic: interface conversion: interface {} is string, not *string
github.com/watson-developer-cloud/go-sdk/assistantv1.(*MessageInput).GetText(...)
panic: interface conversion: interface {} is nil, not string
github.com/watson-developer-cloud/go-sdk/assistantv1.(*MessageInput).GetText(...)
An error occurred while unmarshalling the response body: 'json: cannot unmarshal string into Go struct field MessageRequest.logs.request.alternate_intents of type bool' 

Steps to Reproduce

Perform a simple listlogs operations

func test(workspace string) {
    auth2 := core.IamAuthenticator{
        ApiKey: viper.GetString("watson.apikey"),
    }
    service, serviceErr := assistantv1.NewAssistantV1(&assistantv1.AssistantV1Options{
        Version:       viper.GetString("watson.version"),
        URL:           viper.GetString("watson.url"),
        Authenticator: &auth2,
    })
    if serviceErr != nil {
        fmt.Println(serviceErr)
                panic(serviceErr)
    }
    opts := getOptions(core.StringPtr(""), workspace)
    service.ListLogs(opts)
        result, _, responseErr := service.ListLogs(opts)
        if responseErr != nil {
                fmt.Println(responseErr)
                panic(responseErr)
        }
       b, _ := json.MarshalIndent(result, "", "  ")
       fmt.Println(string(b))
}

func getOptions(cursor *string, workspace string) *assistantv1.ListLogsOptions {
    var limit int64
    limit = int64(100)
    filter := getFilter()
    options := assistantv1.ListLogsOptions{
        WorkspaceID: core.StringPtr(viper.GetString("workspace." + workspace)),
        PageLimit:   &limit,
        Filter:      core.StringPtr(filter),
        Cursor:      cursor,
    }
    return &options
}

SDK Version:

v1.0.0

Additional Info:

ehdsouza commented 4 years ago

@RoloGH thanks for letting us know, Ill check with the service on correct type for MessageRequest.logs.request.alternate_intents.

mediumTaj commented 4 years ago

Looks like in the log response we have input with additional properties.

      "request": {
        "input": {
          "text": "Hello",
          "alternate_intents_s": "true"
        }
      }

There is a field called alternate_intents_s with a string value for boolean. I will check with the service team to see if this is accurate.

@rrberry

ehdsouza commented 4 years ago

@RoloGH, thanks for your patience. The service team is still looking into it and finding the best way for a fix. In the meantime, you could use the python SDK: https://github.com/watson-developer-cloud/python-sdk for list logs.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

mediumTaj commented 4 years ago

Still active

ehdsouza commented 4 years ago

@RoloGH a new version 2020-02-05 is released that fixes this issue. I just tested it out and it works. Could you give it a try?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs. Thank you for your contributions.