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

Creating secure note object fails due to required password field #194

Open
dannysauer opened this issue Aug 20, 2024 · 4 comments
Open

Creating secure note object fails due to required password field #194

dannysauer opened this issue Aug 20, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@dannysauer
Copy link

Your environment

Terraform Provider Version: v2.0.0

Connect Server Version: 1.7.2

CLI Version: 2.30.0

OS: Pop!_OS 22.04 LTS

Terraform Version:

Terraform v1.9.4
on linux_amd64
+ provider registry.terraform.io/1password/onepassword v2.0.0
+ provider registry.terraform.io/barnabyshearer/dockerhub v0.0.15
+ provider registry.terraform.io/hashicorp/google v5.40.0

What happened?

Attempting to create a secure note generated this error message:

│ Error: Provider returned invalid result object after apply
│ 
│ After the apply operation, the provider still indicated an unknown value for
│ onepassword_item.devtokens.password. All values must be known after apply, so
│ this is always a bug in the provider and should be reported in the provider's
│ own repository. Terraform will still save the other known object values in
│ the state.

Then when I added a password field, I got a second error:

╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to onepassword_item.devtokens, provider
│ "provider[\"registry.terraform.io/1password/onepassword\"]" produced an
│ unexpected new value: .section[0].field[0].type: was cty.StringVal("string"),
│ but now cty.StringVal("STRING").
│ 
│ This is a bug in the provider, which should be reported in the provider's own
│ issue tracker.

What did you expect to happen?

I expected a secure note to be created without a password field, and I expected the provider to either internally translate the case of the type or to use an enum to validate acceptable type values.

I also sort of expected the "required" password field to appear in the created item, but there is no password field after it's created. I'm ok with that, though. ;)

Steps to reproduce

  1. Try to create a secure_note item without a password field
  2. Observe error
  3. Add a placeholder password field
  4. Observe that "type = string" in the field is a new error
  5. upper-case the type to STRING
  6. Observe that the created resource does not have a password field even though the provider insists that field is required
resource "onepassword_item" "devtokens" {
  vault = var.op_automation_vault

  title    = "developer tokens"
  category = "secure_note"
  section {
    label = "dev_tokens"
    field {
      label = "a field"
      type  = "string"
      value = "a value"
    }
  }
}

Notes & Logs

I suppose this is technically two separate bugs.

@dannysauer dannysauer added the bug Something isn't working label Aug 20, 2024
@edif2008
Copy link
Member

edif2008 commented Aug 20, 2024

Hey @dannysauer! 👋🏻

What you might be experiencing when it comes to the provider saying the password being required is the bug at #173. This has been solved in the version 2.1.0, which is also the latest version of the provider.

As for the second element that you've identified, that is indeed a bug. A quick mitigation for it is, as you've mentioned, changing the type to STRING. Thank you for catching this. 😄

@dannysauer dannysauer changed the title Creating secure note object fails due to requires password field Creating secure note object fails due to required password field Aug 20, 2024
@dannysauer
Copy link
Author

Oh, that's awesome! Sounds like I have a bug in the Renovate config which is supposed to be updating the 1password provider in my Terraform. :D

@dannysauer
Copy link
Author

Confirmed that deleting the item and recreating without a password field works for me with the new provider. Though, I ran into #97 in the process, so had to delete the item from the state before recreating. ;)

Thanks, @edif2008. Should I open a new bug for the case sensitivity thing, or retitle this one?

@edif2008
Copy link
Member

edif2008 commented Aug 21, 2024

To keep it clean and clear, I would recommend opening a new issue, since this one started off as not being able to create a Secure Note item without a password and in the process the additional bug was found.

Once you make that new issue, I will close this one.

Thank you again for your great cooperation and providing valuable feedback to further improve the Terraform provider. 😄

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