Project
vgrep
Description
The HTTP client in src/server/client.rs lines 89-105 reads the response body without checking Content-Length or Transfer-Encoding headers. When the server uses chunked transfer encoding (common with Axum's streaming responses), the response body includes chunk size markers that corrupt JSON parsing.
Error Message
Error: Failed to parse server response
Caused by:
expected value at line 1 column 1
Debug Logs
System Information
- Bounty Version: 0.1.0
- OS: Ubuntu 24.04 LTS
- Rust: 1.75+
Screenshots
No response
Steps to Reproduce
- Start vgrep server:
vgrep serve
- Index a large codebase with many files
- Perform a search that returns many results:
vgrep "function" -m 100
- Observe intermittent JSON parse failures
Expected Behavior
The HTTP client should:
- Parse response headers to detect
Transfer-Encoding: chunked
- If chunked, decode chunks properly (read size, read data, repeat until size=0)
- If
Content-Length is present, read exactly that many bytes
Actual Behavior
The client reads everything after headers as raw body content, including:
- Chunk size markers (e.g.,
1a\r\n)
- Chunk terminators (
0\r\n\r\n)
This corrupts the JSON response and causes parse failures.
Additional Context
This bug may not manifest in all cases because Axum doesn't always use chunked encoding. Small responses may be sent with Content-Length. The bug is more likely with:
- Large search results
- Many files indexed
- Slow network conditions
Project
vgrep
Description
The HTTP client in
src/server/client.rslines 89-105 reads the response body without checkingContent-LengthorTransfer-Encodingheaders. When the server uses chunked transfer encoding (common with Axum's streaming responses), the response body includes chunk size markers that corrupt JSON parsing.Error Message
Error: Failed to parse server response Caused by: expected value at line 1 column 1Debug Logs
System Information
Screenshots
No response
Steps to Reproduce
vgrep servevgrep "function" -m 100Expected Behavior
The HTTP client should:
Transfer-Encoding: chunkedContent-Lengthis present, read exactly that many bytesActual Behavior
The client reads everything after headers as raw body content, including:
1a\r\n)0\r\n\r\n)This corrupts the JSON response and causes parse failures.
Additional Context
This bug may not manifest in all cases because Axum doesn't always use chunked encoding. Small responses may be sent with
Content-Length. The bug is more likely with: