Skip to content

[BUG] HTTP Client Assumes 200 OK - Silently Ignores Server Errors #73

@EnthusiasticTech

Description

@EnthusiasticTech

Project

vgrep

Description

The custom HTTP client implementation in client.rs skips reading the HTTP status line and assumes all responses are successful. If the server returns 4xx or 5xx errors, the client ignores the status and attempts to parse the error response as a valid JSON result, leading to confusing error messages.

Error Message

Error: Failed to parse server response

Debug Logs

System Information

Bounty Version: 0.1.0
OS: Ubuntu 24.04 LTS
CPU: AMD EPYC-Genoa Processor (8 cores)
RAM: 15 GB

Screenshots

No response

Steps to Reproduce

  1. Start vgrep server
  2. Trigger a server error (e.g., invalid request)
  3. Observe the client error message doesn't mention HTTP status

Expected Behavior

The client should:

  1. Parse and validate the HTTP status line (e.g., HTTP/1.1 200 OK)
  2. Return appropriate errors for non-2xx status codes
  3. Include status code in error messages

Actual Behavior

The client skips status line parsing and reads body directly:

// Read headers (SKIPS status line!)
loop {
    let mut line = String::new();
    reader.read_line(&mut line)?;
    if line == "\r\n" || line.is_empty() {
        break;
    }
}

// Read body (assumes success)
reader.read_to_string(&mut response)?;

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingvalidValid issuevgrep

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions