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

[3.25] okta_app_user_schema_property JSON errors #1087

Closed
virgofx opened this issue May 3, 2022 · 13 comments
Closed

[3.25] okta_app_user_schema_property JSON errors #1087

virgofx opened this issue May 3, 2022 · 13 comments
Assignees
Labels
bug okta-sdk-golang Issue is related to upstream okta-sdk-golang regression

Comments

@virgofx
Copy link
Contributor

virgofx commented May 3, 2022

Starting with version 3.25 the okta_app_user_schema_property now errors out for plan/applies/imports. Downgrading back to version 3.24 there are no issues.

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

Terraform Version

Terraform v1.1.7

Affected Resource(s)

  • okta_app_user_schema_property

Terraform Configuration Files

resource "okta_app_user_schema_property" "test" {}

Steps to Reproduce

I'm testing a default Google Workspace preconfigured App with emailAddresses configured. Link

terraform import okta_app_user_schema_property.test  0oaczr3XXXXXXXXXX/emailAliases

Output

okta_app_user_schema_property.test: Refreshing state... [id=0oaczr3XXXXXXXXXX/emailAliases]
╷
│ Error: failed to get application user schema property: json: cannot unmarshal object into Go struct field UserSchemaAttributeItems.definitions.base.properties.items.enum of type string

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@virgofx virgofx changed the title [3.25] okta_app_user_schema_property JSON errors [3.25] okta_app_user_schema_property JSON errors May 3, 2022
@monde monde self-assigned this May 3, 2022
@monde monde added the bug label May 3, 2022
@monde
Copy link
Collaborator

monde commented May 3, 2022

Seems like the okta-sdk-golang upgrade had some type capabilities shift on it. Regressions make me so blue. Thanks for the details @exitcode0

@virgofx
Copy link
Contributor Author

virgofx commented May 20, 2022

Any chance this could get prioritized for next release @monde , thanks :)

@monde
Copy link
Collaborator

monde commented May 20, 2022

@virgofx the acceptance test isn't kicking off the issue you are having. It uses this TF https://github.com/okta/terraform-provider-okta/blob/master/examples/okta_app_user_schema_property/basic.tf . How does your config look different? Email me directly if you don't to show it in the public.

@virgofx
Copy link
Contributor Author

virgofx commented May 23, 2022

So after more investigation, the issue occurs when attempting to import/apply when crossing over between 3.24 to separate version. There must be some sort of JSON/data incompatibility.

When I removed the resource, then upgraded to 3.27 and then re-applied, everything works.

So I'll close this issue for now as there is a workaround. If anyone experiences this, simply remove the resources via old provider and then re-create via new provider.

@virgofx virgofx closed this as completed May 23, 2022
@virgofx virgofx reopened this May 23, 2022
@virgofx
Copy link
Contributor Author

virgofx commented May 23, 2022

Ack. I was testing with 3.24 actually. Ignore previous comment. Investigating further.

@monde
Copy link
Collaborator

monde commented May 23, 2022

@virgofx send me a snippet of your config. I was going to do a release today but will be tomorrow. Perhaps this will make it in.

@virgofx
Copy link
Contributor Author

virgofx commented May 24, 2022

Here ya go @monde

I was a little swamped today so wasn't able to debug. If you're able to check it out before me, great ;P

# Create an app / google workspace

resource "okta_app_user_schema_property" "test" {
    app_id        = "XXXXXXXXXXXXXXXX" # Update this to ID of google workspace app
    array_enum    = []
    array_type    = "string"
    description   = "Google Email Aliases (must match domain name(s) configured in Google)"
    external_name = "emailAliases"
    index         = "emailAliases"
    master        = "PROFILE_MASTER"
    permissions   = "READ_ONLY"
    required      = false
    scope         = "SELF"
    title         = "Email Aliases"
    type          = "array"
    union         = false
    user_type     = "default"
}
 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" {

@monde
Copy link
Collaborator

monde commented May 24, 2022

@virgofx granted my ACC test is with an oauth app in #1140 , even so, I'm not getting your serialization error.
I'd like to see the TF_LOG=1 output of your plan/apply/test. The serialization error seems to be coming from okta-sdk-golang and not the TF provider itself. Perhaps there aren't flexible enough guards on serialization of an object of nested objects (e.g. UserSchemaAttributeItems.definitions.base.properties.items.enum).

@monde
Copy link
Collaborator

monde commented May 24, 2022

Paired with @virgofx . Looks like the return from the API is not matching the schema in https://github.com/okta/okta-management-openapi-spec which in turn is causing a serialization error in okta-sdk-golang. He'll open a bug on okta-sdk-golang.

@virgofx
Copy link
Contributor Author

virgofx commented Jun 27, 2022

@monde I haven't tested yet but should 3.30 fix this?

@monde
Copy link
Collaborator

monde commented Jun 27, 2022

@virgofx yes try out v3.30.0 . I was just in the process of looking through any of the existing open issues that may benefit from this.

@monde
Copy link
Collaborator

monde commented Jun 27, 2022

v3.30.0 addresses this, please reopen if this isn't addressed correctly. One thing to note is the terraform runtime statically defines the schema at runtime and so we had make enum and one_of.const be string but under the hood the type ensures we handle the JSON call to the API correctly. Here's an example for integer:

resource "okta_app_user_schema_property" "flex_sb_nesting" {
  # ...
  array_type  = "integer"
  array_enum  = ["4", "5"]
  array_one_of {
    const = "4"
    title = "four"
  }
  array_one_of {
    const = "5"
    title = "five"
  }
  #...
}

See "important note on" https://registry.terraform.io/providers/okta/okta/latest/docs/resources/app_user_schema_property that talks about enum/one_of

@monde monde closed this as completed Jun 27, 2022
@virgofx
Copy link
Contributor Author

virgofx commented Jun 30, 2022

@monde I've confirmed that 3.30.0 resolves the issue. Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug okta-sdk-golang Issue is related to upstream okta-sdk-golang regression
Projects
None yet
Development

No branches or pull requests

2 participants