Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserSchema.UpdateApplicationUserProfile JSON Unmarshall Error #304

Closed
virgofx opened this issue May 24, 2022 · 7 comments
Closed

UserSchema.UpdateApplicationUserProfile JSON Unmarshall Error #304

virgofx opened this issue May 24, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@virgofx
Copy link

virgofx commented May 24, 2022

/cc @monde

Describe the bug?

Looks like there's an issue with UpdateApplicationUserProfile with specific requests/responses where JSON deserialization error occurs.

Surfaced from downstream Terraform provider (Ref: okta/terraform-provider-okta#1087)

From Terraform:

okta\resource_okta_app_user_custom_schema_property.go

_, _, err := getOktaClientFromMetadata(m).UserSchema.UpdateApplicationUserProfile(ctx, d.Get("app_id").(string), *custom)

Results in:

 Error: failed to update custom app user schema property: json: cannot unmarshal object into Go struct field UserSchemaAttributeItems.definitions.base.properties.items.enum of type string│
│   with okta_app_user_schema_property.test,
│   on apps.tf line 15, in resource "okta_app_user_schema_property" "test":
│   15: resource "okta_app_user_schema_property" "test" {

What is expected to happen?

Calling UpdateApplicationUserProfile does not error when unmarshalling/decoding the JSON.

What is the actual behavior?

 Error: failed to update custom app user schema property: json: cannot unmarshal object into Go struct field UserSchemaAttributeItems.definitions.base.properties.items.enum of type string│

Reproduction Steps?

Request
POST /api/v1/meta/schemas/apps/{APP_ID}/default HTTP/1.1

{
 "definitions": {
  "custom": {
   "id": "#custom",
   "properties": {
    "emailAliases": {
     "description": "Google Email Aliases (must match domain name(s) configured in Google)",
     "externalName": "emailAliases",
     "items": {
      "type": "string"
     },
     "master": {
      "type": "PROFILE_MASTER"
     },
     "permissions": [
      {
       "action": "READ_ONLY",
       "principal": "SELF"
      }
     ],
     "required": false,
     "scope": "SELF",
     "title": "Email Aliases",
     "type": "array",
     "union": "DISABLE"
    }
   },
   "type": "object"
  }
 }
}

Response

{
 "id": "<app-id>",
 "$schema": "http://json-schema.org/draft-04/schema#",
 "name": "google",
 "title": "Google Workspace User",
 "lastUpdated": "2022-05-23T19:28:09.000Z",
 "created": "2022-01-25T00:29:17.000Z",
 "definitions": {
  "custom": {
   "id": "#custom",
   "type": "object",
   "properties": {
    "emailAliases": {
     "title": "Email Aliases",
     "description": "Google Email Aliases (must match domain name(s) configured in Google)",
     "type": "array",
     "externalName": "emailAliases",
     "scope": "SELF",
     "items": {
      "type": "string"
     },
     "union": "DISABLE",
     "master": {
      "type": "PROFILE_MASTER"
     }
    }
   },
   "required": []
  },
  "base": {
   "id": "#base",
   "type": "object",
   "properties": {
    "userName": {
     "title": "Username",
     "type": "string",
     "required": true,
     "scope": "NONE",
     "maxLength": 100,
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "nameGivenName": {
     "title": "First name",
     "type": "string",
     "required": true,
     "scope": "SELF",
     "minLength": 1,
     "maxLength": 50,
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "nameFamilyName": {
     "title": "Last name",
     "type": "string",
     "required": true,
     "scope": "SELF",
     "minLength": 1,
     "maxLength": 50,
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "emailsWorkAddress": {
     "title": "Work email",
     "description": "Work email",
     "type": "string",
     "scope": "SELF",
     "maxLength": 100,
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "emailsOtherAddress": {
     "title": "Second email",
     "description": "Secondary email",
     "type": "string",
     "scope": "SELF",
     "maxLength": 100,
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "phonesWorkValue": {
     "title": "Primary phone",
     "description": "Phone number.",
     "type": "string",
     "scope": "SELF",
     "maxLength": 100,
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "phonesWorkMobileValue": {
     "title": "Mobile phone",
     "description": "Mobile phone number.",
     "type": "string",
     "scope": "SELF",
     "maxLength": 100,
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "orgUnitPath": {
     "title": "Organizational unit",
     "type": "string",
     "format": "ref-id",
     "scope": "NONE",
     "objectName": "GoogleOrganizationUnit",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "addressesWorkStreetAddress": {
     "title": "Street address",
     "description": "Street address.",
     "type": "string",
     "scope": "SELF",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "addressesWorkLocality": {
     "title": "City",
     "description": "Locality.",
     "type": "string",
     "scope": "SELF",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "addressesWorkRegion": {
     "title": "State",
     "description": "Region.",
     "type": "string",
     "scope": "SELF",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "addressesWorkPostalCode": {
     "title": "Zip code",
     "description": "Postal code.",
     "type": "string",
     "scope": "SELF",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "addressesWorkCountryCode": {
     "title": "Country code",
     "description": "Country code.",
     "type": "string",
     "scope": "SELF",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "organizationsWorkName": {
     "title": "Organizations name",
     "description": "Name of the organization",
     "type": "string",
     "scope": "SELF",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "organizationsWorkTitle": {
     "title": "Organizations title",
     "description": "Title (designation) of the user in the organization.",
     "type": "string",
     "scope": "SELF",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "organizationsWorkDepartment": {
     "title": "Organizations department",
     "description": "Department within the organization.",
     "type": "string",
     "scope": "SELF",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "organizationsWorkCostCenter": {
     "title": "Organizations costCenter",
     "description": "The cost center of the users department.",
     "type": "string",
     "scope": "SELF",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "relationsManagerValue": {
     "title": "Manager ",
     "description": "The name of the manager. Must be a valid email in the domain",
     "type": "string",
     "scope": "SELF",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "unassignmentConfig": {
     "title": "Deactivation options (default is to suspend user)",
     "description": "Provide options to not suspend user and remove all licenses on user unassignment",
     "type": "array",
     "scope": "NONE",
     "items": {
      "type": "object",
      "enum": [
       {
        "name": "Do not suspend user",
        "value": "no-suspend-user"
       },
       {
        "name": "Remove all G Suite licenses",
        "value": "remove-licenses"
       },
       {
        "name": "Remove all G Suite Roles",
        "value": "remove-roles"
       }
      ],
      "properties": {
       "name": {
        "title": "name",
        "description": "name",
        "type": "string"
       },
       "value": {
        "title": "value",
        "description": "value",
        "type": "string"
       }
      },
      "additionalProperties": true
     },
     "uniqueItems": true,
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "manageLicenses": {
     "title": "Manage licenses on create and update",
     "description": "Manage license on user assignment and profile push",
     "type": "boolean",
     "default": false,
     "scope": "NONE",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "licenses": {
     "title": "Licenses",
     "description": "Assign and un-assign licenses",
     "type": "array",
     "scope": "NONE",
     "items": {
      "type": "object",
      "enum": [
       {
        "name": "Google Apps for Business",
        "productID": "Google-Apps",
        "skuID": "Google-Apps-For-Business"
       },
       {
        "name": "Google Apps for Postini",
        "productID": "Google-Apps",
        "skuID": "Google-Apps-For-Postini"
       },
       {
        "name": "Google Apps Unlimited",
        "productID": "Google-Apps",
        "skuID": "Google-Apps-Unlimited"
       },
       {
        "name": "Google Apps Lite",
        "productID": "Google-Apps",
        "skuID": "Google-Apps-Lite"
       },
       {
        "name": "G Suite Enterprise",
        "productID": "Google-Apps",
        "skuID": "1010020020"
       },
       {
        "name": "Google Workspace Business Starter",
        "productID": "Google-Apps",
        "skuID": "1010020027"
       },
       {
        "name": "Google Workspace Business Standard",
        "productID": "Google-Apps",
        "skuID": "1010020028"
       },
       {
        "name": "Google Workspace Business Plus",
        "productID": "Google-Apps",
        "skuID": "1010020025"
       },
       {
        "name": "Google Workspace Enterprise Essentials",
        "productID": "Google-Apps",
        "skuID": "1010060003"
       },
       {
        "name": "Google Workspace Enterprise Standard",
        "productID": "Google-Apps",
        "skuID": "1010020026"
       },
       {
        "name": "Google Workspace Frontline",
        "productID": "Google-Apps",
        "skuID": "1010020030"
       },
       {
        "name": "Google Workspace for Education Standard",
        "productID": "101031",
        "skuID": "1010310005"
       },
       {
        "name": "Google Workspace for Education Standard (Staff)",
        "productID": "101031",
        "skuID": "1010310006"
       },
       {
        "name": "Google Workspace for Education Standard (Extra Student)",
        "productID": "101031",
        "skuID": "1010310007"
       },
       {
        "name": "Google Workspace for Education Plus",
        "productID": "101031",
        "skuID": "1010310008"
       },
       {
        "name": "Google Workspace for Education Plus (Staff)",
        "productID": "101031",
        "skuID": "1010310009"
       },
       {
        "name": "Google Workspace for Education Plus (Extra Student)",
        "productID": "101031",
        "skuID": "1010310010"
       },
       {
        "name": "Google Workspace for Education: Teaching and Learning Upgrade",
        "productID": "101037",
        "skuID": "1010370001"
       },
       {
        "name": "G Suite Enterprise for Education",
        "productID": "101031",
        "skuID": "1010310002"
       },
       {
        "name": "G Suite Enterprise for Education (Student)",
        "productID": "101031",
        "skuID": "1010310003"
       },
       {
        "name": "Google Drive Storage 20GB",
        "productID": "Google-Drive-storage",
        "skuID": "Google-Drive-storage-20GB"
       },
       {
        "name": "Google Drive Storage 50GB",
        "productID": "Google-Drive-storage",
        "skuID": "Google-Drive-storage-50GB"
       },
       {
        "name": "Google Drive Storage 200GB",
        "productID": "Google-Drive-storage",
        "skuID": "Google-Drive-storage-200GB"
       },
       {
        "name": "Google Drive Storage 400GB",
        "productID": "Google-Drive-storage",
        "skuID": "Google-Drive-storage-400GB"
       },
       {
        "name": "Google Drive Storage 1TB",
        "productID": "Google-Drive-storage",
        "skuID": "Google-Drive-storage-1TB"
       },
       {
        "name": "Google Drive Storage 2TB",
        "productID": "Google-Drive-storage",
        "skuID": "Google-Drive-storage-2TB"
       },
       {
        "name": "Google Drive Storage 4TB",
        "productID": "Google-Drive-storage",
        "skuID": "Google-Drive-storage-4TB"
       },
       {
        "name": "Google Drive Storage 8TB",
        "productID": "Google-Drive-storage",
        "skuID": "Google-Drive-storage-8TB"
       },
       {
        "name": "Google Drive Storage 16TB",
        "productID": "Google-Drive-storage",
        "skuID": "Google-Drive-storage-16TB"
       },
       {
        "name": "Google Vault",
        "productID": "Google-Vault",
        "skuID": "Google-Vault"
       },
       {
        "name": "Google Vault Former Employee",
        "productID": "Google-Vault",
        "skuID": "Google-Vault-Former-Employee"
       },
       {
        "name": "Cloud Identity",
        "productID": "101001",
        "skuID": "1010010001"
       },
       {
        "name": "Cloud Identity Premium",
        "productID": "101005",
        "skuID": "1010050001"
       },
       {
        "name": "Google Voice Starter",
        "productID": "101033",
        "skuID": "1010330003"
       },
       {
        "name": "Google Voice Standard",
        "productID": "101033",
        "skuID": "1010330004"
       },
       {
        "name": "Google Voice Premier",
        "productID": "101033",
        "skuID": "1010330002"
       }
      ],
      "properties": {
       "name": {
        "title": "name",
        "description": "name",
        "type": "string"
       },
       "productID": {
        "title": "productID",
        "description": "productID",
        "type": "string"
       },
       "skuID": {
        "title": "skuID",
        "description": "skuID",
        "type": "string"
       }
      },
      "additionalProperties": true
     },
     "uniqueItems": true,
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "afwUserId": {
     "title": "AFW User Id",
     "type": "string",
     "scope": "SYSTEM",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "manageRoles": {
     "title": "Manage roles on create and update",
     "description": "Manage roles on user assignment and profile push",
     "type": "boolean",
     "default": false,
     "scope": "NONE",
     "master": {
      "type": "PROFILE_MASTER"
     }
    },
    "roles": {
     "title": "Roles",
     "description": "Assign and un-assign roles",
     "type": "array",
     "scope": "NONE",
     "items": {
      "type": "string",
      "format": "ref-id",
      "objectName": "GoogleAppRole"
     },
     "master": {
      "type": "PROFILE_MASTER"
     }
    }
   },
   "required": [
    "userName",
    "nameGivenName",
    "nameFamilyName"
   ]
  }
 },
 "type": "object",
 "properties": {
  "profile": {
   "allOf": [
    {
     "$ref": "#/definitions/custom"
    },
    {
     "$ref": "#/definitions/base"
    }
   ]
  }
 }
}

Additional Information?

No response

Golang Version

go 1.17

SDK Version

= v2.12.1

OS version

No response

@virgofx virgofx added the bug Something isn't working label May 24, 2022
@github-actions
Copy link

github-actions bot commented Jun 8, 2022

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 github-actions bot added the stale label Jun 8, 2022
@virgofx
Copy link
Author

virgofx commented Jun 8, 2022

Any chance we can get this slotted in the eng/dev cycle ? This is blocking our upstream Terraform version jump :(

@monde
Copy link
Collaborator

monde commented Jun 10, 2022

@virgofx this is now the top item in my current sprint, fyi

@monde
Copy link
Collaborator

monde commented Jun 14, 2022

fyi @virgofx #312

@monde
Copy link
Collaborator

monde commented Jun 14, 2022

I'm going to do a TF PR that uses this branch and see if this will help out on the schema bugs.

@virgofx
Copy link
Author

virgofx commented Jun 15, 2022

Thanks @monde - I'll test that TF PR branch as well to confirm, can you link me to the branch when you create it.

@monde
Copy link
Collaborator

monde commented Jun 22, 2022

Fixed released in https://github.com/okta/okta-sdk-golang/releases/tag/v2.13.0

@monde monde closed this as completed Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants