Stop asinfo-gen when the as.csv download breaks off (closes #177) #178

Merged
clawbot merged 1 commits from issue-177-asinfo-gen-read-error into next 2026-10-27 03:10:41 +01:00
Collaborator

Fixes #177.

What changed. parseCSV in cmd/asinfo-gen used to skip a record on any read error. A broken download of as.csv makes the response body return the same error on every read, so the generator logged "Error reading CSV record" forever. Now it skips only a record that does not parse, a csv.ParseError. Any other read error is returned, so main exits non-zero and script/asupdate keeps the old list.

Test. TestParseCSVStopsWhenTheDownloadBreaksOff gives parseCSV a header and one record, then a reader that fails with io.ErrUnexpectedEOF on every call. A cut-off HTTP body gives that error. The test runs parseCSV on its own goroutine and gives up after two seconds, so the old code fails the test instead of hanging it.

Disclosures.

  • Judgement call: the check uses errors.AsType, the generic form of errors.As, because the linter asks for it.
  • Judgement call: README.md is unchanged. Its text on script/asupdate already says the old list stays whenever the generator fails.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/routewatch/issues/177. **What changed.** `parseCSV` in `cmd/asinfo-gen` used to skip a record on any read error. A broken download of `as.csv` makes the response body return the same error on every read, so the generator logged "Error reading CSV record" forever. Now it skips only a record that does not parse, a `csv.ParseError`. Any other read error is returned, so `main` exits non-zero and `script/asupdate` keeps the old list. **Test.** `TestParseCSVStopsWhenTheDownloadBreaksOff` gives `parseCSV` a header and one record, then a reader that fails with `io.ErrUnexpectedEOF` on every call. A cut-off HTTP body gives that error. The test runs `parseCSV` on its own goroutine and gives up after two seconds, so the old code fails the test instead of hanging it. **Disclosures.** - Judgement call: the check uses `errors.AsType`, the generic form of `errors.As`, because the linter asks for it. - Judgement call: `README.md` is unchanged. Its text on `script/asupdate` already says the old list stays whenever the generator fails. Model: opus-5-5
clawbot added the needs-review label 2026-10-27 02:50:02 +01:00
clawbot self-assigned this 2026-10-27 02:50:03 +01:00
Author
Collaborator

FAIL (needs-rework)

  • cmd/asinfo-gen/main_test.go: no test checks that a record that does not parse is still logged and skipped. #177 requires that skip to stay, and the new csv.ParseError check in parseCSV (cmd/asinfo-gen/main.go, line 113) is what keeps it. If that check stopped matching, parseCSV would end on the first such record and every test would still pass. Acceptable: a test that parses an as.csv with a record that does not parse, such as one with too few fields, between two valid records, and expects both valid ASes back with no error.

Judgement call: the issue's definition of done names only the broken-download test. I ask for this one too because the issue names the skip as required behaviour and this change rewrites the check that keeps it.

Model: opus-5-5

**FAIL** (needs-rework) - `cmd/asinfo-gen/main_test.go`: no test checks that a record that does not parse is still logged and skipped. https://git.eeqj.de/sneak/routewatch/issues/177 requires that skip to stay, and the new `csv.ParseError` check in `parseCSV` (`cmd/asinfo-gen/main.go`, line 113) is what keeps it. If that check stopped matching, `parseCSV` would end on the first such record and every test would still pass. Acceptable: a test that parses an `as.csv` with a record that does not parse, such as one with too few fields, between two valid records, and expects both valid ASes back with no error. Judgement call: the issue's definition of done names only the broken-download test. I ask for this one too because the issue names the skip as required behaviour and this change rewrites the check that keeps it. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-27 02:58:13 +01:00
clawbot added 1 commit 2026-10-27 03:01:00 +01:00
parseCSV skipped a record on any read error and asked for the next one.
When the download of as.csv broke off, the response body returned the
same error on every read, so the generator logged it forever and make
asupdate never finished.

parseCSV now skips only a record that does not parse, a csv.ParseError.
Any other read error ends it with that error, so the generator exits
non-zero and script/asupdate keeps the old list.

Model: opus-5-5
clawbot force-pushed issue-177-asinfo-gen-read-error from 7e1c6f9598 to 772a5c6ba3 2026-10-27 03:01:00 +01:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-27 03:01:05 +01:00
Author
Collaborator

Rework for #178 (comment):

  • Fixed: TestParseCSVSkipsARecordThatDoesNotParse in cmd/asinfo-gen/main_test.go, amended into the one commit.

Model: opus-5-5

Rework for https://git.eeqj.de/sneak/routewatch/pulls/178#issuecomment-157532: - Fixed: `TestParseCSVSkipsARecordThatDoesNotParse` in `cmd/asinfo-gen/main_test.go`, amended into the one commit. Model: opus-5-5
Author
Collaborator

PASS: parseCSV now skips only a record that does not parse and ends with an error on any other read failure, and TestParseCSVSkipsARecordThatDoesNotParse fixes the finding of #178 (comment).

Model: opus-5-5

**PASS**: `parseCSV` now skips only a record that does not parse and ends with an error on any other read failure, and `TestParseCSVSkipsARecordThatDoesNotParse` fixes the finding of https://git.eeqj.de/sneak/routewatch/pulls/178#issuecomment-157532. Model: opus-5-5
clawbot merged commit cd1b9b94a4 into next 2026-10-27 03:10:41 +01:00
clawbot deleted branch issue-177-asinfo-gen-read-error 2026-10-27 03:10:41 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/routewatch#178