ory/hydra · error

new request: %s

Error message

new request: %s

What it means

Returned by fetchRemote when retryablehttp.NewRequestWithContext rejects the source URL — the URL is malformed for the HTTP client (bad control characters, invalid percent-encoding, or unparseable host), even though scheme dispatch accepted it. The source is redacted in the message to avoid leaking embedded credentials.

Source

Thrown at oryx/fetcher/fetcher.go:163

	if f.cache != nil {
		cacheKey := sha256.Sum256([]byte(source))
		if v, ok := f.cache.Get(cacheKey[:]); ok {
			b = make([]byte, len(v))
			copy(b, v)
			return b, nil
		}
		defer func() {
			if err == nil && len(b) > 0 {
				toCache := make([]byte, len(b))
				copy(toCache, b)
				f.cache.SetWithTTL(cacheKey[:], toCache, int64(len(toCache)), f.ttl)
			}
		}()
	}

	req, err := retryablehttp.NewRequestWithContext(ctx, http.MethodGet, source, nil)
	if err != nil {
		return nil, errors.Wrapf(err, "new request: %s", redactedSource(source))
	}
	res, err := f.hc.Do(req)
	if err != nil {
		return nil, errors.Wrap(err, redactedSource(source))
	}
	defer res.Body.Close()

	if res.StatusCode != http.StatusOK {
		return nil, errors.Errorf("expected http response status code 200 but got %d when fetching: %s", res.StatusCode, redactedSource(source))
	}

	if f.limit > 0 {
		var buf bytes.Buffer
		n, err := io.Copy(&buf, io.LimitReader(res.Body, f.limit+1))
		if n > f.limit {
			return nil, bytes.ErrTooLarge
		}
		if err != nil {

View on GitHub (pinned to 4174065ffb)

Solutions

  1. URL-encode or clean the source string so net/url can parse it
  2. Validate the configured source URL at startup with url.ParseRequestURI
  3. Check for stray whitespace, newlines, or unescaped characters in the URL
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at oryx/fetcher/fetcher.go:163 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ory/hydra@4174065ffb (2026-09-03). Data as JSON: /api/errors/32384bed8da44f8b. Report an issue: GitHub.