Skip to content

fix(no-ticket): send zero entitlement limits to the API - #557

Draft
cloudsmith-iduffy wants to merge 1 commit into
masterfrom
iduffy/fix-entitlement-zero-limits
Draft

cloudsmith-iduffy wants to merge 1 commit into
masterfrom
iduffy/fix-entitlement-zero-limits

Conversation

@cloudsmith-iduffy

Copy link
Copy Markdown
Collaborator

Description

cloudsmith entitlements restrict dropped a value of 0 for --limit-num-clients, --limit-num-downloads and --limit-bandwidth. The command used a truthiness check, so 0 never reached the request. The CLI sent an empty PATCH, showed OK and exited 0, and the limit stayed the same.

The API reads 0 as "no limit" for all three fields, so 0 is the only way to remove one of these limits from the CLI. The command now sends any value that you give, including 0. The help text for the three options now says that 0 removes the limit.

Before:

$ cloudsmith entitlements restrict my-org/my-repo/TOKEN --limit-num-clients 0
Updating TOKEN entitlement for the my-repo repository ... OK
# request body: (empty)

After:

$ cloudsmith entitlements restrict my-org/my-repo/TOKEN --limit-num-clients 0
Updating TOKEN entitlement for the my-repo repository ... OK
# request body: {"limit_num_clients": 0}

With no limit options, the command does the same as before: it sends an empty PATCH.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Other (please describe)

Additional Notes

I marked this as a breaking change because a script can depend on the old behavior. For example, a script that passes --limit-num-downloads "${LIMIT:-0}" used 0 as "do not change". Now that call removes the current limit on the token.

The string options (--limit-package-query, --limit-path-query, the dates, the unit and --refresh-token) keep their current checks. An empty string for the unit, the dates or the refresh period is not a valid API value.

🤖 Generated with Claude Code

The restrict command dropped a value of 0 for --limit-num-clients,
--limit-num-downloads and --limit-bandwidth. It sent an empty PATCH and
showed OK. The API reads 0 as no limit, so the CLI now sends 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 24, 2026 18:07
@cloudsmith-iduffy cloudsmith-iduffy added the breaking change Changes behaviour that scripts or users can depend on label Oct 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused fix correctly distinguishes zero from omitted values and includes regression coverage for all three affected options.

No open issues 🎉

What changed in this PR

Fixes cloudsmith entitlements restrict so explicit zero values reach the API and remove numeric limits, while omitted options remain unchanged.

Changes:

  • Replaces truthiness checks with explicit None checks for all three numeric limits.
  • Adds regression tests verifying each zero value appears in the PATCH body.
  • Documents zero-value behavior in option help and the changelog.
File Description
cloudsmith_cli/​cli/​tests/​commands/​test_entitlements.py Tests zero-value request payloads for all three limits.
cloudsmith_cli/​cli/​commands/​entitlements.py Preserves explicit zeros, clarifies help, and adds type annotations.
CHANGELOG.md Records the corrected zero-value behavior.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Changes behaviour that scripts or users can depend on

Development

Successfully merging this pull request may close these issues.

2 participants