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: removing last rule from firewall fails with invalid_input error #696

Merged
merged 3 commits into from
Feb 13, 2024

Conversation

kossmac
Copy link
Contributor

@kossmac kossmac commented Feb 12, 2024

If you try to delete last firewall rule, rule is null but should be [], resulting in error message

hcloud: invalid input in field 'rules' (invalid_input)

hcloud firewall delete-rule --direction in --protocol tcp --source-ips '8.8.8.8/32' --port 443 f2b

@kossmac kossmac requested a review from a team as a code owner February 12, 2024 21:02
Copy link
Member

@apricote apricote left a comment

Choose a reason for hiding this comment

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

Very nice catch!

Could you update the tests to check for an empty array? This line should have []hcloud.FirewallRule{} instead of nil: https://github.com/hetznercloud/cli/blob/main/internal/cmd/firewall/delete_rule_test.go#L39

Copy link

codecov bot commented Feb 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6dd443f) 58.78% compared to head (9643257) 58.78%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #696   +/-   ##
=======================================
  Coverage   58.78%   58.78%           
=======================================
  Files         179      179           
  Lines        6536     6536           
=======================================
  Hits         3842     3842           
  Misses       2087     2087           
  Partials      607      607           

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

@apricote apricote changed the title bug: send empty FirewallRule instead of null when deleting last rule fix: removing last rule from firewall fails with invalid_input error Feb 13, 2024
Copy link
Member

@apricote apricote left a comment

Choose a reason for hiding this comment

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

Awesome!

Updated the title for our Changelog.

@apricote apricote merged commit acab17c into hetznercloud:main Feb 13, 2024
3 checks passed
phm07 pushed a commit that referenced this pull request Apr 3, 2024
🤖 I have created a release *beep* *boop*
---


##
[1.43.0](v1.42.0...v1.43.0)
(2024-04-03)


### Features

* allow deletion of multiple resources at once
([#719](#719))
([3b896fe](3b896fe))
* improve missing argument error messages
([#711](#711))
([e7f9e74](e7f9e74))
* **server:** allow JSON & YAML output in reset-password
([#716](#716))
([373287b](373287b)),
closes [#715](#715)


### Bug Fixes

* removing last rule from firewall fails with invalid_input error
([#696](#696))
([acab17c](acab17c))

---
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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants