Overview
This guide helps you diagnose and fix common issues when running HTTPSpec tests. Errors are categorized by type with explanations of error messages and solutions.Parse Errors
Parse errors occur when HTTPSpec cannot parse your.http or .httpspec file.
InvalidRequestMissingMethod
Error Message:InvalidRequestMissingURL
Error Message:InvalidHttpVersion
Error Message:HTTP/1.0HTTP/1.1(default)HTTP/2HTTP/3
InvalidHeaderFormat
Error Message:Name: Value format.
Source: parser.zig:172
Solution:
Headers must have a colon (
:) separating the name and value. Whitespace around the colon is trimmed.InvalidAssertionFormat
Error Message:Valid Assertion Components
Valid Assertion Components
Keys:
status- HTTP status codebody- Response body contentheader["name"]- Specific header value
==,equal!=,not_equalcontainsnot_containsstarts_withends_withmatches_regexnot_matches_regex
- Any string (quotes are optional unless value contains spaces)
Assertion Failures
Assertion failures occur when responses don’t match expected values. HTTPSpec reports detailed failure information.Understanding Failure Messages
Failure messages follow this format (assertion_checker.zig:120-138):status_mismatch
Error Message:Check API Response
Check API Response
- Verify the API endpoint is correct
- Check request headers and body
- Ensure the server is running
- Review server logs for errors
Update Expected Value
Update Expected Value
If the API behavior has changed:
Use Range Checks
Use Range Checks
For flexible status checking:
header_mismatch
Error Message:Header value comparison is case-insensitive (assertion_checker.zig:207).
header_missing
Error Message:Verify Header Name
Verify Header Name
Check for typos in the header name:
Check Server Response
Check Server Response
Use curl or another tool to inspect actual headers:
Optional Header Check
Optional Header Check
If the header should be absent:
body_mismatch
Error Message:Use Flexible Matching
Use Flexible Matching
Instead of exact equality, use
contains:Use Regex for Patterns
Use Regex for Patterns
Match dynamic content:
Debug Response Body
Debug Response Body
Temporarily remove the assertion to see actual response:
contains_failed
Error Message:not_contains_failed
Error Message:invalid_assertion_key
Error Message:status, body, or header["..."].
Source: assertion_checker.zig:135, 211, 234, 256, 278, 300, 322
Solution:
statusbodyheader["header-name"](note the double quotes)
status_format_error
Error Message:Status codes must be numeric values (e.g., 200, 404, 500).
Connection Issues
Connection errors occur when HTTPSpec cannot reach the target server.Failed to Execute Request
Error Message:Server Not Running
Server Not Running
Symptoms: Connection refused, connection timeoutSolution:
- Verify the server is running
- Check the correct port
- Ensure no firewall blocking
Incorrect URL
Incorrect URL
Symptoms: DNS resolution errors, 404 responsesSolution:
SSL/TLS Issues
SSL/TLS Issues
Symptoms: Certificate verification errorsSolution:
- Check certificate validity
- Ensure correct hostname
- Verify system CA certificates are up to date
Network Connectivity
Network Connectivity
Symptoms: Timeout errorsSolution:
Invalid File Format
File Not Found
Error Message:- Verify file path is correct
- Check file exists
- Ensure proper file extension (
.httpor.httpspec)
Empty File
Cause: The.http file contains no valid requests.
Solution:
Ensure file has at least one valid HTTP request:
Thread Pool Configuration
Too Many Threads
Symptoms:- Excessive memory usage
- Server overload
- Rate limit errors
HTTP_THREAD_COUNT:
Thread Allocation Errors
Error Message:- Reduce thread count
- Check system resource limits
- Close other applications
Debugging Tips
Enable Detailed Error Output
HTTPSpec outputs errors to stderr. Capture for debugging:Isolate Failing Tests
Run one test file at a time:Simplify Assertions
Temporarily remove complex assertions:Use External Tools
Test requests independently:Check Memory Leaks
HTTPSpec uses a debug allocator in development (main.zig:11-13):- Reducing test file size
- Limiting parallel execution
- Checking for large response bodies
Reading Error Messages
Error Message Format
HTTPSpec error messages include:- Error type: The specific error that occurred
- File location: Which test file failed (if applicable)
- Details: Expected vs actual values
Test Summary Report
After all tests run, HTTPSpec reports:- Pass: Test file ran with all assertions passing
- Fail: Test file ran but one or more assertions failed
- Invalid: Test file could not be parsed or executed
Common Patterns
Intermittent Failures
Causes:- Network instability
- Server load
- Race conditions in parallel execution
- Non-deterministic API responses
Authentication Issues
Symptoms: 401 Unauthorized, 403 Forbidden Solution:CORS Errors
Note: HTTPSpec is a CLI tool and doesn’t encounter browser CORS restrictions. If you see CORS-related content in responses, it indicates server-side issues.Getting Help
Check Documentation
- Assertion Operators - Complete operator reference
- Environment Variables - Configuration options
- Quick Start - Getting started guide
Report Issues
If you encounter a bug:- Create a minimal reproduction case
- Include HTTPSpec version
- Provide error messages
- Share relevant
.httpfile (sanitized)
Community Support
Reach out through:- GitHub Issues
- Project documentation
- Community forums
See Also
- Assertion Operators - Detailed operator documentation
- Environment Variables - Configuration reference
- HTTP File Format - File syntax guide