Commit 1c836cd
authored
fix(fetchers): surface malformed body errors (#104)
## What
Treat malformed zero-byte response bodies as fetch errors instead of
successful empty responses.
Closes #98.
## Why
`read_body_with_timeout()` collapsed a body-stream failure before the
first chunk into `(empty, false)`. That let malformed chunked responses
look like successful `200 OK` fetches with empty content, and the same
path could also create misleading zero-byte files under `save_to_file`.
## How
- change `read_body_with_timeout()` to return `FetchError` when the body
stream fails before any bytes are read
- preserve partial-body behavior for mid-stream failures by returning
the partial bytes as `truncated=true`
- propagate the new result through the default fetcher and direct
`llms.txt` docs-site path
- add regressions for malformed chunked responses in both normal fetch
and `save_to_file` flows
## Risk
- Low
- Changes only the malformed-body error path; successful responses,
timeouts, size caps, and partial-body truncation stay on the existing
behavior
### Checklist
- [x] Unit tests are passed
- [x] Smoke tests are passed
- [ ] Documentation is updated
- [x] Specs are up to date and not in conflict
- [x] `cargo fmt --all` is passed
- [x] `cargo clippy --workspace --all-targets -- -D warnings` is passed
- [x] `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` is
passed
- [x] `cargo build --workspace --exclude fetchkit-python --release` is
passed1 parent afbc233 commit 1c836cd
3 files changed
Lines changed: 57 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
| 295 | + | |
| 296 | + | |
296 | 297 | | |
297 | 298 | | |
298 | 299 | | |
| |||
438 | 439 | | |
439 | 440 | | |
440 | 441 | | |
441 | | - | |
| 442 | + | |
| 443 | + | |
442 | 444 | | |
443 | 445 | | |
444 | 446 | | |
| |||
644 | 646 | | |
645 | 647 | | |
646 | 648 | | |
647 | | - | |
| 649 | + | |
648 | 650 | | |
649 | 651 | | |
650 | 652 | | |
| |||
660 | 662 | | |
661 | 663 | | |
662 | 664 | | |
663 | | - | |
| 665 | + | |
664 | 666 | | |
665 | 667 | | |
666 | 668 | | |
667 | 669 | | |
668 | | - | |
| 670 | + | |
669 | 671 | | |
670 | 672 | | |
671 | 673 | | |
672 | 674 | | |
673 | 675 | | |
674 | | - | |
675 | | - | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
676 | 680 | | |
677 | 681 | | |
678 | 682 | | |
679 | | - | |
| 683 | + | |
680 | 684 | | |
681 | 685 | | |
682 | 686 | | |
683 | 687 | | |
684 | 688 | | |
685 | | - | |
| 689 | + | |
686 | 690 | | |
687 | 691 | | |
688 | 692 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
| 242 | + | |
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
35 | 56 | | |
36 | 57 | | |
37 | 58 | | |
| |||
55 | 76 | | |
56 | 77 | | |
57 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
58 | 101 | | |
59 | 102 | | |
60 | 103 | | |
| |||
0 commit comments