Skip to content

fix(firewall): do not require --startport for ICMP rules#585

Merged
giornetta merged 3 commits into
civo:masterfrom
alubbock:fix/icmp-firewall-rule-no-startport
May 12, 2026
Merged

fix(firewall): do not require --startport for ICMP rules#585
giornetta merged 3 commits into
civo:masterfrom
alubbock:fix/icmp-firewall-rule-no-startport

Conversation

@alubbock
Copy link
Copy Markdown
Contributor

ICMP is a portless protocol, so --startport should not be mandatory when creating firewall rules with --protocol=ICMP.

Two issues were found and fixed:

  1. MarkFlagRequired("startport") was enforced globally by Cobra before the command ran, making it impossible to omit regardless of protocol. Removed the declaration and replaced it with a runtime check that only errors for TCP/UDP.

  2. The Civo API is case-sensitive: it only skips the port-empty validation when protocol is sent as lowercase "icmp". Sending "ICMP" triggered a 400 firewall_ports_should_not_be_empty error even though start_port and end_port were present as empty strings in the JSON body. Fixed by normalising protocol to lowercase before building the request config.

EndPort assignment and success output messages are also updated to omit port information for ICMP rules.

Fixes #350

ICMP is a portless protocol, so --startport should not be mandatory
when creating firewall rules with --protocol=ICMP.

Two issues were found and fixed:

1. MarkFlagRequired("startport") was enforced globally by Cobra before
   the command ran, making it impossible to omit regardless of protocol.
   Removed the declaration and replaced it with a runtime check that
   only errors for TCP/UDP.

2. The Civo API is case-sensitive: it only skips the port-empty
   validation when protocol is sent as lowercase "icmp". Sending "ICMP"
   triggered a 400 firewall_ports_should_not_be_empty error even though
   start_port and end_port were present as empty strings in the JSON
   body. Fixed by normalising protocol to lowercase before building the
   request config.

EndPort assignment and success output messages are also updated to
omit port information for ICMP rules.
@giornetta giornetta self-requested a review May 11, 2026 16:18
Copy link
Copy Markdown
Member

@giornetta giornetta left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@giornetta giornetta merged commit ea9193f into civo:master May 12, 2026
3 checks passed
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.

Create Firewall Rule for ICMP Requires Starting Port Number

3 participants