okta-sdk-golang icon indicating copy to clipboard operation
okta-sdk-golang copied to clipboard

Unmarshaling error in IdentityProviderApplicationUser.Profile field when calling ListIdentityProviderApplicationUsers

Open moemoeq opened this issue 7 months ago • 6 comments

Describe the bug?

The IdentityProviderApplicationUser struct in the Okta Go SDK v5 has an issue with the Profile field deserialization. When calling ListIdentityProviderApplicationUsers, the API returns JSON with a nested object in the profile field, but the SDK fails to unmarshal it with an error:

json: cannot unmarshal string into Go struct field _IdentityProviderApplicationUser.profile of type map[string]interface {}

I believe the IdentityProviderApplicationUser type should be map[string]interface{} instead map[string]map[string]interface{}

https://github.com/okta/okta-sdk-golang/blob/ffc6fb8734627501772eebc29797769ee2cbbb90/okta/model_identity_provider_application_user.go#L31-L40

What is expected to happen?

The SDK should correctly unmarshal the JSON response into the IdentityProviderApplicationUser struct, with the Profile field properly populated as a map[string]interface{} containing all the profile attributes from the JSON response.

What is the actual behavior?

The SDK throws a JSON unmarshaling error when processing the response: json: cannot unmarshal string into Go struct field _IdentityProviderApplicationUser.profile of type map[string]interface{}

Reproduction Steps?

Use the Okta Go SDK v5.0.5 Create a client with proper authentication Call the following code:

func ListIdpUsers(client *okta.APIClient, idpId string) {
    ctx := context.Background()
    users, resp, err := client.IdentityProviderAPI.ListIdentityProviderApplicationUsers(ctx, idpId).Execute()
    if err != nil {
        fmt.Printf("Error: %v\n", err)
        return
    }
    fmt.Printf("Response: %+v\n", resp)
}

Additional Information?

fix IdentityProviderApplicationUser struct like this with change related function and boom! works

type IdentityProviderApplicationUser struct {
	Created              *string                           `json:"created,omitempty"`
	ExternalId           *string                           `json:"externalId,omitempty"`
	Id                   *string                           `json:"id,omitempty"`
	LastUpdated          *string                           `json:"lastUpdated,omitempty"`
	Profile              map[string]interface{}            `json:"profile,omitempty"`
	Embedded             map[string]map[string]interface{} `json:"_embedded,omitempty"`
	Links                *LinksSelf                        `json:"_links,omitempty"`
	AdditionalProperties map[string]interface{}
}

Sample Response (censored)

{
    "id": "00uxxxxxxxxxxxxxxxx",
    "externalId": "[email protected]",
    "created": "2024-07-22T05:04:28.000Z",
    "lastUpdated": "2025-05-08T02:22:39.000Z",
    "profile": {
      "lastName": "Doe",
      "subjectConfirmationMethod": "urn:oasis:names:tc:SAML:2.0:cm:bearer",
      "jobtitle": "Team Member",
      "authnmethodsreferences": "http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password",
      "objectidentifier": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "identityprovider": "https://sts.windows.net/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/",
      "subjectSpProvidedId": null,
      "authNContextClassRef": "urn:oasis:names:tc:SAML:2.0:ac:classes:Password",
      "subjectConfirmationAddress": null,
      "firstName": "(Dev_Team)",
      "subjectSpNameQualifier": null,
      "mobilePhone": "+xx xx-xxxx-xxxx",
      "subjectNameFormat": "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
      "subjectNameQualifier": null,
      "tenantid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "department": "DEV / R&D / Team",
      "subjectNameId": "[email protected]",
      "email": "[email protected]"
    },
    "_links": {
      "idp": {
        "href": "https://example.okta.com/api/v1/idps/0oaxxxxxxxxxx"
      },
      "self": {
        "href": "https://example.okta.com/api/v1/idps/0oaxxxxxxxxxx/users/00uxxxxxxxxxxxxxxxx",
        "hints": {
          "allow": [
            "GET",
            "DELETE"
          ]
        }
      },
      "user": {
        "href": "https://example.okta.com/api/v1/users/00uxxxxxxxxxxxxxxxx"
      }
    }
}

Golang Version

1.24.2

SDK Version

v5.0.5

OS version

Darwin MYMAC.local 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6030 arm64

moemoeq avatar May 08 '25 06:05 moemoeq

This issue has been marked stale because there has been no activity within the last 14 days. To keep this issue active, remove the stale label.

github-actions[bot] avatar May 23 '25 02:05 github-actions[bot]

I am having the same issue

michaeldop avatar Sep 02 '25 18:09 michaeldop

not stale

moemoeq avatar Sep 03 '25 01:09 moemoeq

This issue has been marked stale because there has been no activity within the last 14 days. To keep this issue active, remove the stale label.

github-actions[bot] avatar Sep 17 '25 02:09 github-actions[bot]

Not stale

moemoeq avatar Sep 17 '25 08:09 moemoeq

This issue has been marked stale because there has been no activity within the last 14 days. To keep this issue active, remove the stale label.

github-actions[bot] avatar Oct 02 '25 02:10 github-actions[bot]

This is also causing the same issue in v6

tim-koehler avatar Nov 20 '25 14:11 tim-koehler