From fce1b6d37db7147aa1ac3497c3ef557fa0d44557 Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Fri, 21 Aug 2026 09:54:48 -0700 Subject: [PATCH 1/3] Handle receiving HTTP error codes (non-200) when downloading files. Related to [this forum thread](https://forum.exercism.org/t/cli-silently-creates-0-byte-files-when-file-downloads-hit-http-429-rate-limit/75208/). --- cmd/download.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/download.go b/cmd/download.go index 0e74c49ed..4208faaed 100644 --- a/cmd/download.go +++ b/cmd/download.go @@ -80,6 +80,7 @@ func runDownload(cfg config.Config, flags *pflag.FlagSet, args []string) error { return err } + var successes int for _, sf := range download.payload.files() { url, err := sf.url() if err != nil { @@ -98,8 +99,10 @@ func runDownload(cfg config.Config, flags *pflag.FlagSet, args []string) error { defer res.Body.Close() if res.StatusCode != http.StatusOK { - // TODO: deal with it - continue + if successes > 0 { + fmt.Fprintf(Err, "Downloaded %d/%d files", successes, len(download.payload.files())) + } + return fmt.Errorf("received HTTP/%d when fetching %#v", res.StatusCode, url) } path := sf.relativePath() From f060de3959b95013d6f43d0854887e5f86474b9e Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Fri, 21 Aug 2026 12:12:10 -0700 Subject: [PATCH 2/3] Increment success count after writing file --- cmd/download.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/download.go b/cmd/download.go index 4208faaed..1ef6b041d 100644 --- a/cmd/download.go +++ b/cmd/download.go @@ -120,6 +120,7 @@ func runDownload(cfg config.Config, flags *pflag.FlagSet, args []string) error { if err != nil { return err } + successes++ } fmt.Fprintf(Err, "\nDownloaded to\n") fmt.Fprintf(Out, "%s\n", metadata.Dir) From 5f5d7b00fdc8b9bff2889f98d8916f0a482c2243 Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Fri, 21 Aug 2026 15:37:47 -0700 Subject: [PATCH 3/3] Add trailing newline to print --- cmd/download.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/download.go b/cmd/download.go index 1ef6b041d..165ad91bb 100644 --- a/cmd/download.go +++ b/cmd/download.go @@ -100,7 +100,7 @@ func runDownload(cfg config.Config, flags *pflag.FlagSet, args []string) error { if res.StatusCode != http.StatusOK { if successes > 0 { - fmt.Fprintf(Err, "Downloaded %d/%d files", successes, len(download.payload.files())) + fmt.Fprintf(Err, "Downloaded %d/%d files\n", successes, len(download.payload.files())) } return fmt.Errorf("received HTTP/%d when fetching %#v", res.StatusCode, url) }