Repository navigation
fix(no-ticket): send zero entitlement limits to the API - #557
Draft
cloudsmith-iduffy wants to merge 1 commit into
Draft
cloudsmith-iduffy wants to merge 1 commit into
cloudsmith-iduffy wants to merge 1 commit into
Conversation
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>
Contributor
There was a problem hiding this comment.
🟢 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
Nonechecks 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
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.
Description
cloudsmith entitlements restrictdropped a value of 0 for--limit-num-clients,--limit-num-downloadsand--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:
After:
With no limit options, the command does the same as before: it sends an empty PATCH.
Type of Change
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