fix(firewall): do not require --startport for ICMP rules#585
Merged
giornetta merged 3 commits intoMay 12, 2026
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ICMP is a portless protocol, so --startport should not be mandatory when creating firewall rules with --protocol=ICMP.
Two issues were found and fixed:
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.
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