Skip to content

fix(cli): reject negative rule flags given on their own - #506

Open
pcbeingused333 wants to merge 1 commit into
hookdeck:mainfrom
pcbeingused333:fix/rule-flag-zero-validation
Open

pcbeingused333 wants to merge 1 commit into
hookdeck:mainfrom
pcbeingused333:fix/rule-flag-zero-validation

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Follow-up to #498 (validate rule flags in connection update).

validateRules decides whether a rule is being configured with RuleDelay > 0, RuleDeduplicateWindow > 0, RuleRetryCount > 0 and RuleRetryInterval > 0. A negative value therefore never counts as "set", and the must be a positive integer checks further down (< 0) are only reachable when some other flag in the same rule is also given. On its own, --rule-delay -5 is silently ignored: the command succeeds and sends no rule. The same goes for --rule-deduplicate-window -5 and for a lone negative retry count/interval.

Fix. Use != 0 in those four "has flags" checks, so the existing validation errors fire. Valid (positive) values and unset flags behave as before; this matches the != 0 checks connection upsert already uses to detect rule flags.

Test. TestConnectionUpdateRejectsNegativeRuleFlags covers each flag on its own (and negative retry count/interval with and without --rule-retry-strategy); it fails on main (no error returned) and passes with the change. go test ./pkg/cmd/ passes.

Reproduction. hookdeck gateway connection update <id> --rule-delay -5 exits successfully without applying or rejecting anything.

This PR was prepared with AI assistance (Claude Code) and the contributor is responsible for the change.

The has-rule-flags checks in validateRules only counted values > 0, so a
lone negative --rule-delay, --rule-deduplicate-window,
--rule-retry-count or --rule-retry-interval skipped validation and was
silently ignored. Count any non-zero value so the existing errors fire.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

1 participant