cisco-open / terraform-provider-meraki

A Terraform Provider for Cisco Meraki
Mozilla Public License 2.0
15 stars 6 forks source link

meraki_organizations_early_access_features_opt_ins Error #128

Closed tagur87 closed 3 weeks ago

tagur87 commented 1 month ago

Prerequisites

Describe the bug When trying to configure organization level early opt in features, with the below configuration (no limiting scope to network), we get a type conversion error.

Relevant Configuration

resource "meraki_organizations_early_access_features_opt_ins" "this" {
  limit_scope_to_networks = []
  organization_id         = "1153381"
  short_name              = "has_mx_no_nat_early_access"
}

Error

 Error: Value Conversion Error
│ 
│   with meraki_organizations_early_access_features_opt_ins.this,
│ An unexpected error was encountered trying to convert tftypes.Value into provider.OrganizationsEarlyAccessFeaturesOptInsRs. This is always an error in the provider. Please report the following to the provider developer:
│ 
│ mismatch between struct and object: Struct defines fields not found in object: limit_scope_to_networks_rs.

Expected behavior Opt in early access feature would work successfully, as it does in the API.

Screenshots image

Environment (please complete the following information):

Additional context

Trace Logs:

2024-07-30T11:33:18.362-0400 [TRACE] provider.terraform-provider-meraki_v0.2.9-alpha: Served request: tf_provider_addr=registry.terraform.io/CiscoDevNet/meraki @module=sdk.proto tf_proto_version=6.6 tf_req_id=d51571d0-e830-1104-752b-3f5cbf6124df tf_resource_type=meraki_organizations_early_access_features_opt_ins tf_rpc=PlanResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:843 timestamp=2024-07-30T11:33:18.359-0400
2024-07-30T11:33:18.362-0400 [TRACE] provider.terraform-provider-meraki_v0.2.9-alpha: Received request: tf_rpc=ApplyResourceChange @module=sdk.proto tf_provider_addr=registry.terraform.io/CiscoDevNet/meraki tf_resource_type=meraki_organizations_early_access_features_opt_ins @caller=github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:852 tf_proto_version=6.6 tf_req_id=f628c9cd-fed1-9c6a-ec81-708df4b4d4ed timestamp=2024-07-30T11:33:18.360-0400
2024-07-30T11:33:18.362-0400 [TRACE] provider.terraform-provider-meraki_v0.2.9-alpha: Sending request downstream: tf_resource_type=meraki_organizations_early_access_features_opt_ins tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/tf6serverlogging/downstream_request.go:22 tf_proto_version=6.6 @module=sdk.proto tf_provider_addr=registry.terraform.io/CiscoDevNet/meraki tf_req_id=f628c9cd-fed1-9c6a-ec81-708df4b4d4ed timestamp=2024-07-30T11:33:18.360-0400
2024-07-30T11:33:18.362-0400 [TRACE] provider.terraform-provider-meraki_v0.2.9-alpha: Checking ResourceTypes lock: tf_rpc=ApplyResourceChange @module=sdk.framework tf_provider_addr=registry.terraform.io/CiscoDevNet/meraki tf_req_id=f628c9cd-fed1-9c6a-ec81-708df4b4d4ed tf_resource_type=meraki_organizations_early_access_features_opt_ins @caller=github.com/hashicorp/terraform-plugin-framework@v1.7.0/internal/fwserver/server.go:420 timestamp=2024-07-30T11:33:18.360-0400
2024-07-30T11:33:18.362-0400 [TRACE] provider.terraform-provider-meraki_v0.2.9-alpha: ApplyResourceChange received no PriorState, running CreateResource: @caller=github.com/hashicorp/terraform-plugin-framework@v1.7.0/internal/fwserver/server_applyresourcechange.go:45 @module=sdk.framework tf_provider_addr=registry.terraform.io/CiscoDevNet/meraki tf_req_id=f628c9cd-fed1-9c6a-ec81-708df4b4d4ed tf_resource_type=meraki_organizations_early_access_features_opt_ins tf_rpc=ApplyResourceChange timestamp=2024-07-30T11:33:18.360-0400
2024-07-30T11:33:18.362-0400 [TRACE] provider.terraform-provider-meraki_v0.2.9-alpha: Resource implements ResourceWithConfigure: tf_provider_addr=registry.terraform.io/CiscoDevNet/meraki tf_req_id=f628c9cd-fed1-9c6a-ec81-708df4b4d4ed @caller=github.com/hashicorp/terraform-plugin-framework@v1.7.0/internal/fwserver/server_createresource.go:47 @module=sdk.framework tf_resource_type=meraki_organizations_early_access_features_opt_ins tf_rpc=ApplyResourceChange timestamp=2024-07-30T11:33:18.360-0400
2024-07-30T11:33:18.362-0400 [TRACE] provider.terraform-provider-meraki_v0.2.9-alpha: Calling provider defined Resource Configure: @caller=github.com/hashicorp/terraform-plugin-framework@v1.7.0/internal/fwserver/server_createresource.go:54 tf_provider_addr=registry.terraform.io/CiscoDevNet/meraki tf_req_id=f628c9cd-fed1-9c6a-ec81-708df4b4d4ed tf_resource_type=meraki_organizations_early_access_features_opt_ins @module=sdk.framework tf_rpc=ApplyResourceChange timestamp=2024-07-30T11:33:18.360-0400
2024-07-30T11:33:18.362-0400 [TRACE] provider.terraform-provider-meraki_v0.2.9-alpha: Called provider defined Resource Configure: tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-framework@v1.7.0/internal/fwserver/server_createresource.go:56 @module=sdk.framework tf_provider_addr=registry.terraform.io/CiscoDevNet/meraki tf_req_id=f628c9cd-fed1-9c6a-ec81-708df4b4d4ed tf_resource_type=meraki_organizations_early_access_features_opt_ins timestamp=2024-07-30T11:33:18.360-0400
2024-07-30T11:33:18.362-0400 [TRACE] provider.terraform-provider-meraki_v0.2.9-alpha: Calling provider defined Resource Create: tf_req_id=f628c9cd-fed1-9c6a-ec81-708df4b4d4ed tf_resource_type=meraki_organizations_early_access_features_opt_ins @caller=github.com/hashicorp/terraform-plugin-framework@v1.7.0/internal/fwserver/server_createresource.go:100 @module=sdk.framework tf_provider_addr=registry.terraform.io/CiscoDevNet/meraki tf_rpc=ApplyResourceChange timestamp=2024-07-30T11:33:18.360-0400
2024-07-30T11:33:18.362-0400 [TRACE] provider.terraform-provider-meraki_v0.2.9-alpha: Called provider defined Resource Create: tf_req_id=f628c9cd-fed1-9c6a-ec81-708df4b4d4ed tf_resource_type=meraki_organizations_early_access_features_opt_ins @caller=github.com/hashicorp/terraform-plugin-framework@v1.7.0/internal/fwserver/server_createresource.go:102 tf_provider_addr=registry.terraform.io/CiscoDevNet/meraki @module=sdk.framework tf_rpc=ApplyResourceChange timestamp=2024-07-30T11:33:18.360-0400
2024-07-30T11:33:18.362-0400 [TRACE] provider.terraform-provider-meraki_v0.2.9-alpha: Received downstream response: tf_provider_addr=registry.terraform.io/CiscoDevNet/meraki tf_req_duration_ms=0 @caller=github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/tf6serverlogging/downstream_request.go:42 @module=sdk.proto tf_proto_version=6.6 tf_req_id=f628c9cd-fed1-9c6a-ec81-708df4b4d4ed tf_resource_type=meraki_organizations_early_access_features_opt_ins tf_rpc=ApplyResourceChange diagnostic_error_count=1 diagnostic_warning_count=0 timestamp=2024-07-30T11:33:18.360-0400
2024-07-30T11:33:18.362-0400 [ERROR] provider.terraform-provider-meraki_v0.2.9-alpha: Response contains error diagnostic: diagnostic_attribute="" tf_provider_addr=registry.terraform.io/CiscoDevNet/meraki @module=sdk.proto diagnostic_summary="Value Conversion Error" tf_proto_version=6.6 tf_req_id=f628c9cd-fed1-9c6a-ec81-708df4b4d4ed tf_resource_type=meraki_organizations_early_access_features_opt_ins tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/diag/diagnostics.go:58
  diagnostic_detail=
  | An unexpected error was encountered trying to convert tftypes.Value into provider.OrganizationsEarlyAccessFeaturesOptInsRs. This is always an error in the provider. Please report the following to the provider developer:
  | 
  | mismatch between struct and object: Struct defines fields not found in object: limit_scope_to_networks_rs.
   diagnostic_severity=ERROR timestamp=2024-07-30T11:33:18.360-0400
2024-07-30T11:33:18.363-0400 [TRACE] provider.terraform-provider-meraki_v0.2.9-alpha: Served request: @caller=github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:878 tf_provider_addr=registry.terraform.io/CiscoDevNet/meraki tf_req_id=f628c9cd-fed1-9c6a-ec81-708df4b4d4ed tf_rpc=ApplyResourceChange @module=sdk.proto tf_proto_version=6.6 tf_resource_type=meraki_organizations_early_access_features_opt_ins timestamp=2024-07-30T11:33:18.360-0400
╷
│ Error: Value Conversion Error
│ 
│   with meraki_organizations_early_access_features_opt_ins.this,
│ An unexpected error was encountered trying to convert tftypes.Value into provider.OrganizationsEarlyAccessFeaturesOptInsRs. This is always an error in the provider. Please report the following to the provider developer:
│ 
│ mismatch between struct and object: Struct defines fields not found in object: limit_scope_to_networks_rs.
╵
2024-07-30T11:33:18.376-0400 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-07-30T11:33:18.376-0400 [INFO]  provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/cisco-open/meraki/0.2.9-alpha/darwin_arm64/terraform-provider-meraki_v0.2.9-alpha id=12973
2024-07-30T11:33:18.376-0400 [DEBUG] provider: plugin exited
fmunozmiranda commented 1 month ago

@tagur87 please try it with new version and update us.

tagur87 commented 1 month ago

I was able to get it to work, but still ran into some other errors.

  1. If you try to create the opt_in without the opt_in_id field defined, you get this error:

    meraki_organizations_early_access_features_opt_ins.this: Creating...
    ╷
    │ Error: Provider produced inconsistent result after apply
    │ 
    │ When applying changes to meraki_organizations_early_access_features_opt_ins.this, provider "provider[\"registry.terraform.io/cisco-open/meraki\"]" produced an unexpected new value: .opt_in_id: was null, but now cty.StringVal("762234236932510422").
    │ 
    │ This is a bug in the provider, which should be reported in the provider's own issue tracker.

    You can get around this by setting opt_in_id to "", however this should not be required.

  2. After applying and adding the opt in using the above "trick", you cannot destroy the parameter to remove the opt in. You get an error on the destroy like follows:

data.meraki_organizations_early_access_features.this: Reading...
meraki_organizations_early_access_features_opt_ins.this: Refreshing state... [id=762234236932510424]
data.meraki_organizations_early_access_features.this: Read complete after 0s
╷
│ Error: Failure when executing GetOrganizationEarlyAccessFeaturesOptIn
│ 
│   with meraki_organizations_early_access_features_opt_ins.this,
│   on main.tf line 20, in resource "meraki_organizations_early_access_features_opt_ins" "this":
│   20: resource "meraki_organizations_early_access_features_opt_ins" "this" {
│ 
│ json: cannot unmarshal array into Go value of type meraki.ResponseOrganizationsGetOrganizationEarlyAccessFeaturesOptIn
╵
tagur87 commented 1 month ago

Not sure why opt_in_id is even in the terraform resource as a parameter? ACcording to the API docs, there is no such field returned. https://developer.cisco.com/meraki/api-v1/create-organization-early-access-features-opt-in/

Just the id field, which can then be used as then optInId in the URL to read the id. https://developer.cisco.com/meraki/api-v1/get-organization-early-access-features-opt-ins/

Seems this is some bug in the provider generator code.

fmunozmiranda commented 4 weeks ago

Please try it with new version and update us.

tagur87 commented 3 weeks ago

This worked. Thanks for the help.