Skip to content

Commit dcddce4

Browse files
authored
Fix 429 rate limit handling and context key type mismatch in login #480 (#481)
fix: handle 429 rate limit and context key type mismatch in login issue #480
1 parent a3fa2f0 commit dcddce4

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

cmd/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func loginCmd() *cobra.Command {
4747
Use: "login",
4848
Short: "Login to the App Store",
4949
RunE: func(cmd *cobra.Command, args []string) error {
50-
interactive, _ := cmd.Context().Value(interactiveKey).(bool)
50+
interactive := cmd.Context().Value(interactiveKey).(bool)
5151

5252
if password == "" && !interactive {
5353
return errors.New("password is required when not running in interactive mode; use the \"--password\" flag")

pkg/http/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ func (c *client[R]) handleXMLResponse(res *http.Response) (Result[R], error) {
160160
return Result[R]{}, fmt.Errorf("failed to read response body: %w", err)
161161
}
162162

163+
if res.StatusCode == http.StatusTooManyRequests {
164+
return Result[R]{}, fmt.Errorf("rate limited by Apple (HTTP %d): %s", res.StatusCode, strings.TrimSpace(string(body)))
165+
}
166+
163167
var data R
164168

165169
normalizedBody := normalizeXMLPlistBody(body)

0 commit comments

Comments
 (0)