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

fix(ssh-key): data inconsistency with empty label objects #922

Merged
merged 1 commit into from
May 2, 2024

Conversation

apricote
Copy link
Member

@apricote apricote commented May 2, 2024

When we implemented the Label helper we added some extra logic that handled the difference between the label attribute default (null) and the Hetzner Cloud API default ({}). This worked well in our test cases, but breaks if you pass an empty object to the attribute:

When applying changes to hcloud_ssh_key.this, provider "provider[\"registry.terraform.io/hetznercloud/hcloud\"]" produced an unexpected new value: .labels: was cty.MapValEmpty(cty.String), but now null.

We have now fixed this by setting the default of the labels field to an empty object to match the return value of the API. With this, we no longer need the workaround to handle null labels in Terraform config.

Fixes #921

@apricote apricote added the bug label May 2, 2024
@apricote apricote self-assigned this May 2, 2024
@apricote apricote requested a review from a team as a code owner May 2, 2024 10:51
@apricote
Copy link
Member Author

apricote commented May 2, 2024

We have manually tested the various combinations for empty label attributes:

  • No label attribute
  • null
  • {}

We plan to add some more detailed tests in the coming weeks, but wanted to get this fix out immediately.

When we implemented the Label helper we added some extra logic that
handled the difference between the `label` attribute default (null) and
the Hetzner Cloud API default (`{}`). This worked well in our test
cases, but breaks if you pass an empty object to the attribute:

    When applying changes to hcloud_ssh_key.this, provider
    "provider[\"registry.terraform.io/hetznercloud/hcloud\"]" produced
    an unexpected new value: .labels: was cty.MapValEmpty(cty.String),
    but now null.

We have now fixed this by setting the default of the labels field to
an empty object to match the return value of the API. With this, we no
longer need the workaround to handle null labels in Terraform config.

Fixes #921
@apricote apricote force-pushed the ssh-key-label-inconsistency branch from dd8caa4 to f7991a3 Compare May 2, 2024 10:57
Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.76%. Comparing base (800a66c) to head (f7991a3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #922   +/-   ##
=======================================
  Coverage   69.76%   69.76%           
=======================================
  Files          63       63           
  Lines        7938     7938           
=======================================
  Hits         5538     5538           
  Misses       1701     1701           
  Partials      699      699           
Flag Coverage Δ
e2e 69.76% <100.00%> (ø)
unit 34.22% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@apricote apricote merged commit 7e1bf2c into main May 2, 2024
6 checks passed
@apricote apricote deleted the ssh-key-label-inconsistency branch May 2, 2024 12:28
apricote pushed a commit that referenced this pull request May 3, 2024
🤖 I have created a release *beep* *boop*
---


##
[1.47.0](v1.46.1...v1.47.0)
(2024-05-02)


### Features

* test with Terraform 1.8
([#919](#919))
([800a66c](800a66c))


### Bug Fixes

* **ssh-key:** data inconsistency with empty label objects
([#922](#922))
([7e1bf2c](7e1bf2c)),
closes
[#921](#921)
* **subnet:** handle new error message for deleting subnets with
attached resources
([#923](#923))
([932c47b](932c47b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: [hcloud_ssh_key] Error: Provider produced inconsistent result after apply
2 participants