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

state mv returns 0 on invalid source address #29365

Closed
acarapetis opened this issue Aug 13, 2021 · 3 comments
Closed

state mv returns 0 on invalid source address #29365

acarapetis opened this issue Aug 13, 2021 · 3 comments
Labels
bug cli confirmed a Terraform Core team member has reproduced this issue v1.0 Issues (primarily bugs) reported against v1.0 releases
Milestone

Comments

@acarapetis
Copy link

acarapetis commented Aug 13, 2021

Terraform Version

Terraform v1.0.4
on linux_amd64
...

Expected Behavior

When given a source address that does not exist in the state, terraform state mv should exit with a non-zero code to signal failure.

Actual Behavior

An error is printed but 0 is returned.

Steps to Reproduce

  1. touch blank.tf
  2. terraform init
  3. terraform apply
  4. terraform state mv foo.bar1 foo.bar2

It looks like this is an oversight in state_mv.go: in the case where sourceAddrs is empty, an error is added to the diags, but the code that checks diags for errors (and returns 1 if any are found) is only inside the loop over sourceAddrs, so 1 is never returned. I could supply a simple patch to fix the issue, but I'm following the contribution guidelines by opening an issue first instead.

@acarapetis acarapetis added bug new new issue not yet triaged labels Aug 13, 2021
@jbardin jbardin added cli and removed new new issue not yet triaged labels Aug 16, 2021
@alisdair alisdair added confirmed a Terraform Core team member has reproduced this issue v1.0 Issues (primarily bugs) reported against v1.0 releases labels Nov 4, 2021
@alisdair
Copy link
Member

alisdair commented Nov 4, 2021

Thanks for reporting this! I can confirm the issue. There is a pending PR to fix it at #29839.

@alisdair
Copy link
Member

The fix for this issue has been merged and will ship in the next Terraform 1.1 patch release.

@apparentlymart apparentlymart added this to the v1.1.6 milestone Feb 16, 2022
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug cli confirmed a Terraform Core team member has reproduced this issue v1.0 Issues (primarily bugs) reported against v1.0 releases
Projects
None yet
Development

No branches or pull requests

4 participants