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

Fixing plugin crash when providing empty strings to argument #421

Merged
merged 2 commits into from
Jan 25, 2022

Conversation

sebasslash
Copy link
Contributor

@sebasslash sebasslash commented Jan 24, 2022

Description

This is a really simple fix that closes #409 by preventing the user to set the names argument for tfe_data_source_workspace_ids to an array of empty strings or an array that contains empty strings. The reason for this is the plugin sdk fetches empty strings as nil values, causing any type casting operations to panic.

There is an alternative up for discussion, let's say the user provides ["wkspace1", "", "wkspace2"], should the plugin read this as ["wkspace1", "wkspace2"] omitting any entries that are nil? This might be a better alternative as [] is a valid assignment and therefore omitting entries that are nil (in a case where all entries are nil) would effectively be the same as [].

Update: Decided to go with the alternative solution

Testing plan

  1. In order to test ensure you have your provider overrides setup, and have an available Terraform configuration to test with
  2. Create a data source block and apply:
data "tfe_workspace_ids" "this" {
  names = [""],
  organization = "your-org-here"
}
  1. You should have a successful apply

To run acceptance test:

TESTARGS="-run TestAccTFEWorkspaceIDsDataSource_namesEmpty" make testacc

@sebasslash sebasslash requested a review from a team as a code owner January 24, 2022 19:19
Copy link
Contributor

@barrettclark barrettclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add this case to the tests? I also noticed there is a test failure, which may just be a flickering test failure.

@sebasslash
Copy link
Contributor Author

Yeah looks like a flickering test, ran the failed tests locally and they passed.

@brandonc
Copy link
Collaborator

That is a new test we should probably keep an eye on it.

@sebasslash sebasslash merged commit 6a1068a into main Jan 25, 2022
@sebasslash sebasslash deleted the sebasslash/fix-plugin-crash branch January 25, 2022 15:49
@sebasslash sebasslash mentioned this pull request Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Passing [""] to data.tfe_workspace_ids.names crashes plugin
3 participants