ory / sdk

The place where ORY's SDKs are being auto-generated
Apache License 2.0
137 stars 85 forks source link

UiNodes are not unmarshalled in Go kratos SDK #311

Closed kolotaev closed 6 months ago

kolotaev commented 7 months ago

Preflight checklist

Ory Network Project

No response

Describe the bug

GetLoginFlow() (and other methods) of the Go SDK client of ory/kratos v1.0.0 (github.com/ory/kratos-client-go v1.0.0) fails to properly unmarshal UI Nodes.

Reproducing the bug

Expected: the values are not empty.

Actual: the values are empty.

The actual values from the debugger after the incoming JSON from HTTP response was parsed:

Screenshot 2023-12-13 at 22 32 54

The actual incoming JSON:

{
    "id": "df907427-5127-47f1-8507-26576b41469c",
    "type": "browser",
    "expires_at": "2023-12-13T19:00:11.533441Z",
    "issued_at": "2023-12-13T18:00:11.533441Z",
    "request_url": "http://localhost:4433/self-service/login/browser",
    "ui": {
        "action": "http://localhost:4433/self-service/login?flow=df907427-5127-47f1-8507-26576b41469c",
        "method": "POST",
        "nodes": [
            {
                "type": "input",
                "group": "default",
                "attributes": {
                    "name": "csrf_token",
                    "type": "hidden",
                    "value": "r2gw3/r/tBCGlQXhRduiVDoCT9Oj8/DL5DvjP4USVuzDYg+SFg7N3Gummwi//UQA/a3rLmXCJySiSwpcu7JeKg==",
                    "required": true,
                    "disabled": false,
                    "node_type": "input"
                },
                "messages": [],
                "meta": {}
            },
            {
                "type": "input",
                "group": "default",
                "attributes": {
                    "name": "identifier",
                    "type": "text",
                    "value": "",
                    "required": true,
                    "disabled": false,
                    "node_type": "input"
                },
                "messages": [],
                "meta": {
                    "label": {
                        "id": 1070004,
                        "text": "ID",
                        "type": "info"
                    }
                }
            },
            {
                "type": "input",
                "group": "password",
                "attributes": {
                    "name": "password",
                    "type": "password",
                    "required": true,
                    "autocomplete": "current-password",
                    "disabled": false,
                    "node_type": "input"
                },
                "messages": [],
                "meta": {
                    "label": {
                        "id": 1070001,
                        "text": "Password",
                        "type": "info"
                    }
                }
            },
            {
                "type": "input",
                "group": "password",
                "attributes": {
                    "name": "method",
                    "type": "submit",
                    "value": "password",
                    "disabled": false,
                    "node_type": "input"
                },
                "messages": [],
                "meta": {
                    "label": {
                        "id": 1010001,
                        "text": "Sign in",
                        "type": "info",
                        "context": {}
                    }
                }
            }
        ]
    },
    "created_at": "2023-12-13T22:00:11.539785Z",
    "updated_at": "2023-12-13T22:00:11.539785Z",
    "refresh": false,
    "requested_aal": "aal1"
}

I think it's the problem in UnmarshalJSON() function of github.com/ory/kratos-client-go/model_ui_node_attributes.go file . Where it constantly falls into the if match > 1 { // more than 1 match branch.

Relevant log output

There are no errors reported or returned. If fails to parse json silently.

Relevant configuration

No response

Version

1.0.0

On which operating system are you observing this issue?

macOS

In which environment are you deploying?

Binary

Additional Context

It works fine in github.com/ory/kratos-client-go v0.13.1. My Go version is 1.21, MacOS ARM (same is on Linux ARM).

alxdsz commented 7 months ago

Just spent an hour because of this very issue and was going to create one.

aeneasr commented 6 months ago

This should be fixed now!