-
Notifications
You must be signed in to change notification settings - Fork 180
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
fix: : Provider crash when an invalid role name is specified to mongodbatlas_project_api_key
#1720
Conversation
…to mongodbatlas_project_api_key
Failing test is related to another resource Error: -08T10:39:12.578Z [ERROR] sdk.helper_resource: Error running import: test_name=TestAccConfigRSCustomDBRoles_importBasic test_terraform_path=/home/runner/work/_temp/035a6132-4f93-460b-8080-7c833c37c596/terraform test_working_directory=/tmp/plugintest409873591 test_step_number=2
error=
| ImportStateVerify attributes not equivalent. Difference is shown below. The - symbol indicates attributes missing after import.
|
| map[string]string{
| + \t"actions.0.resources.0.cluster": "false",
| }
=== NAME TestAccConfigRSCustomDBRoles_importBasic
resource_custom_db_role_test.go:441: Step 2/2 error running import: ImportStateVerify attributes not equivalent. Difference is shown below. The - symbol indicates attributes missing after import.
map[string]string{
+ "actions.0.resources.0.cluster": "false",
}
--- FAIL: TestAccConfigRSCustomDBRoles_importBasic (417.32s) |
_, err = conn.APIKeys.Delete(ctx, orgID, apiKeyID) | ||
if err != nil { | ||
return diag.FromErr(fmt.Errorf("error unable to delete Key (%s): %s", apiKeyID, err)) | ||
if orgID != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what case will orgID be ""? I believe this is what crashes the provider right (empty orgId passed to Delete API call)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error in the help ticket was caused by the missing return statement at line 108: the endpoint was returning an error which was different than 404 and so line 126 was trying to access apiKey
via apiKey.PublicKey
but apiKey
was null
I discovered this scenario on missing orgID
with this failing test TestAccConfigRSProjectAPIKey_RecreateWhenDeletedExternally
:
=== NAME TestAccConfigRSProjectAPIKey_RecreateWhenDeletedExternally
testing_new.go:91: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error unable to delete Key (6571df9493323a7823188b59): DELETE https://cloud-dev.mongodb.com/api/atlas/v1.0/orgs//apiKeys/6571df9493323a7823188b59: 400 (request "")
The test was deleting the API key manually as part of deleteAPIKeyManually and then the post-destroy was trying to delete the API key that was already deleted.
Description
Ticket: CLOUDP-216402
Issue: Provider crashes when an invalid role name is specified to
mongodbatlas_project_api_key
Type of change:
Required Checklist:
Testing
Local testing
I reproduced the error with v1.13.1
│ Error: Plugin did not respond -- │ │ The plugin encountered an error, and failed to respond to the │ plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may │ contain more details.
I run the same TF config with my changes
│ Error: POST https://cloud-dev.mongodb.com/api/atlas/v1.0/groups/6571a9637db22d780f3cec0c/apiKeys: 400 (request "INVALID_ENUM_VALUE") An invalid enumeration value GROUP_s was specified.
Acceptance Test
I added the acceptance test
TestAccConfigRSProjectAPIKey_Invalid_Role