fix(cli): report GitHub API rate limits in difyctl install scripts#38375
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #38375 +/- ##
==========================================
+ Coverage 85.29% 85.34% +0.05%
==========================================
Files 4992 5147 +155
Lines 264162 268493 +4331
Branches 50126 51184 +1058
==========================================
+ Hits 225309 229140 +3831
- Misses 34434 34934 +500
Partials 4419 4419
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
126e72c to
5088937
Compare
The install scripts resolved releases with `curl -fsSL`, which discards the response body and X-RateLimit-* headers. A rate limit (60 req/hour per unauthenticated IP) was therefore misreported as "release not found" or "failed to query". Classify fetch failures by HTTP status and rate-limit headers, print an actionable hint (reset ETA + how to authenticate), and send GITHUB_TOKEN / GH_TOKEN as a bearer to raise the limit to 5000/hour. Mirrored in install.ps1, with tests for both.
5088937 to
b2cb47f
Compare
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.
Summary
The
difyctlinstall scripts resolve releases through the GitHub REST API withcurl -fsSL.-fdiscards the response body and theX-RateLimit-*headers, so when the API rate limit is hit (60 req/hour per unauthenticated IP — common behind shared NATs, corporate egress, or in CI) the failure was misreported asDify release <x> not foundorfailed to query latest Dify release, sending users to debug the wrong thing.This PR makes the scripts detect and explain rate limiting:
fetch_jsonnow reads the HTTP status and rate-limit headers and classifies the failure (rate limit vs. 404 vs. network) instead of collapsing everything into one opaque exit code.GITHUB_TOKEN/GH_TOKEN, when set, is sent as a bearer token to raise the limit from 60 to 5000 req/hour.install.ps1; unit tests added for both.The success path is unchanged, and non-rate-limit errors keep their original messages.
Screenshots
N/A — CLI install-script change. Example new output when rate limited:
Checklist
GITHUB_TOKENnote is a follow-up;cli/README.mdis updated here.cli/README.md)cli/gates instead of the backend/frontend ones (not applicable here):pnpm lint,pnpm type-check, andviteston the changed suites — all green.