Skip to content

fix(fetchers): surface malformed body errors#104

Merged
chaliy merged 1 commit intomainfrom
fix/issue-98-malformed-body-errors
Apr 15, 2026
Merged

fix(fetchers): surface malformed body errors#104
chaliy merged 1 commit intomainfrom
fix/issue-98-malformed-body-errors

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 15, 2026

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

  • Unit tests are passed
  • Smoke tests are passed
  • Documentation is updated
  • Specs are up to date and not in conflict
  • cargo fmt --all is passed
  • cargo clippy --workspace --all-targets -- -D warnings is passed
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps is passed
  • cargo build --workspace --exclude fetchkit-python --release is passed

@chaliy chaliy merged commit 1c836cd into main Apr 15, 2026
11 checks passed
@chaliy chaliy deleted the fix/issue-98-malformed-body-errors branch April 15, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

malformed response bodies can degrade into false successful empty fetches

1 participant