projectdiscovery/nuclei · error

ErrRebuildURL

ErrRebuildURL

Error message

could not rebuild request URL: %w

What it means

Error "could not rebuild request URL: %w" thrown in projectdiscovery/nuclei.

Source

Thrown at pkg/protocols/http/httpclientpool/clientpool.go:599

}

func checkMaxRedirects(req *http.Request, via []*http.Request, maxRedirects int) error {
	if maxRedirects == 0 {
		if len(via) > defaultMaxRedirects {
			return http.ErrUseLastResponse
		}
		return nil
	}

	if len(via) > maxRedirects {
		return http.ErrUseLastResponse
	}

	// NOTE(dwisiswant0): rebuild request URL. See #5900.
	if u := req.URL.String(); !isURLEncoded(u) {
		parsed, err := urlutil.Parse(u)
		if err != nil {
			return fmt.Errorf("%w: %w", ErrRebuildURL, err)
		}

		req.URL = parsed.URL
	}

	return nil
}

// isURLEncoded is an helper function to check if the URL is already encoded
//
// NOTE(dwisiswant0): shall we move this under `projectdiscovery/utils/urlutil`?
func isURLEncoded(s string) bool {
	decoded, err := url.QueryUnescape(s)
	if err != nil {
		// If decoding fails, it may indicate a malformed URL/invalid encoding.
		return false
	}

View on GitHub (pinned to 265b3a3dec)

When it happens

Trigger: Thrown at pkg/protocols/http/httpclientpool/clientpool.go:599 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15). Data as JSON: /api/errors/373111beee9bba22. Report an issue: GitHub.