owasp-amass/amass · error

failed to provide a valid Amass HTTP request

Error message

failed to provide a valid Amass HTTP request

What it means

RequestWebPage was invoked with a nil *Request argument. It is a simple nil-guard at the top of the function: no URL, method, or headers exist to send, so the HTTP request cannot even be attempted. Only observed from TestRequestWebPage in production code paths.

Source

Thrown at internal/net/http/http.go:173

	}

	return &Response{
		Status:     resp.Status,
		StatusCode: resp.StatusCode,
		Proto:      resp.Proto,
		ProtoMajor: resp.ProtoMajor,
		ProtoMinor: resp.ProtoMinor,
		Header:     HdrToAmassHeader(resp.Header),
		Body:       body,
		Length:     int64(len(body)),
		TLS:        resp.TLS,
	}
}

// RequestWebPage returns the response headers, body, and status code for the provided URL when successful.
func RequestWebPage(ctx context.Context, client *http.Client, r *Request) (*Response, error) {
	if r == nil {
		return nil, errors.New("failed to provide a valid Amass HTTP request")
	}

	if r.Method == "" {
		r.Method = http.MethodGet
	} else if r.Method != http.MethodGet && r.Method != http.MethodPost && r.Method != http.MethodDelete {
		return nil, errors.New("failed to provide a valid HTTP method")
	}

	req, err := http.NewRequestWithContext(ctx, r.Method, r.URL, strings.NewReader(r.Body))
	if err != nil {
		return nil, err
	}
	req.Close = true

	if r.Auth != nil && r.Auth.Username != "" && r.Auth.Password != "" {
		req.SetBasicAuth(r.Auth.Username, r.Auth.Password)
	}

View on GitHub (pinned to 79299dce87)

Solutions

  1. Ensure callers construct and pass a non-nil Request (typically via a helper like NewRequest) before calling RequestWebPage
  2. Return or skip earlier in the calling code when the request would be nil (e.g. optional scraping disabled)
  3. In tests, build a valid Request object instead of passing nil
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/net/http/http.go:173 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06). Data as JSON: /api/errors/3d422292910ef887. Report an issue: GitHub.