Skip to content

fix(ENG-15482): show rate limits when the API leaves out a value - #581

Merged
cloudsmith-iduffy merged 4 commits into
masterfrom
iduffy/fix-ratelimits-null
Nov 3, 2026
Merged

cloudsmith-iduffy merged 4 commits into
masterfrom
iduffy/fix-ratelimits-null

Conversation

@cloudsmith-iduffy

Copy link
Copy Markdown
Collaborator

Description

Sentry CLOUDSMITH-CLI-1V is a TypeError from cloudsmith check rates on 1.30.1: float() argument must be a string or a real number, not 'NoneType'.

get_rate_limits() turns the SDK response into a dict with to_dict(). The SDK model puts every field in that dict, and sets a field that the API leaves out to None:

>>> ResourcesRateCheck(resources={"core": RateCheck(limit=600)}).to_dict()
{'resources': {'core': {'interval': None, 'limit': 600, 'remaining': None, 'reset': None, 'reset_iso_8601': None, 'throttled': None}}}

RateLimitsInfo.from_dict checked "interval" in data, which is always true for this dict, and then called float(None). Each check is now data.get(key) is not None, so a missing value stays None. The table shows None for it, as it already does when the rate limit headers are missing. throttled still falls back to remaining == 0.

Linear: ENG-15482. Fixes CLOUDSMITH-CLI-1V

Type of Change

  • Bug fix

Additional Notes

The patch in ENG-15482 was correct. This PR keeps its fix and cuts the tests to the one case that fails before the fix.

🤖 Generated with Claude Code

The SDK sets each field that the API leaves out to None, so the
"key in data" checks were always true. float(None) then stopped
`cloudsmith check rates` with TypeError.

Fixes CLOUDSMITH-CLI-1V

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 2, 2026 01:30

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

No active review issues remain for the fix to null rate-limit handling.

No open issues 🎉

What changed in this PR

Fixes cloudsmith check rates crashing when the API omits rate-limit values that the SDK represents as None.

Changes:

  • Skip conversions for missing or null values while preserving the remaining == 0 fallback for throttled status.
  • Add a regression test covering null fields.
  • Document the fix in the changelog.
File Description
cloudsmith_cli/​core/​tests/​test_ratelimits.py Tests null-field handling and the throttled fallback.
cloudsmith_cli/​core/​ratelimits.py Guards conversions against None values.
CHANGELOG.md Records the rate-limit display fix.

Review effort: Balanced

@cloudsmith-iduffy
cloudsmith-iduffy marked this pull request as ready for review November 2, 2026 13:25
@cloudsmith-iduffy
cloudsmith-iduffy requested a review from a team as a code owner November 2, 2026 13:25
@cloudsmith-iduffy

Copy link
Copy Markdown
Collaborator Author

@copilot resolve the merge conflicts in this pull request

…ts-null

# Conflicts:
#	CHANGELOG.md

Co-authored-by: cloudsmith-iduffy <178375997+cloudsmith-iduffy@users.noreply.github.com>

Copilot AI commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved in 8a152c3 by merging master and retaining both sets of changelog entries. The rate-limit fix and regression test are unchanged. The regression test passed when invoked directly; pytest is unavailable in this environment.

* origin/master:
  fix(ENG-15484): accept --color on click versions before 8.2 (#582)

# Conflicts:
#	CHANGELOG.md

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

No active review issues block the fix for crashes caused by missing or null rate-limit values.

No open issues 🎉

Review effort: Balanced

@cloudsmith-iduffy
cloudsmith-iduffy enabled auto-merge (squash) November 3, 2026 14:53
@cloudsmith-iduffy
cloudsmith-iduffy merged commit 08e903d into master Nov 3, 2026
19 checks passed
@cloudsmith-iduffy
cloudsmith-iduffy deleted the iduffy/fix-ratelimits-null branch November 3, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants