ory/hydra · error
expected http response status code 200 but got %d when fetch
Error message
expected http response status code 200 but got %d when fetching: %s
What it means
Returned by fetchRemote when the HTTP request succeeded but the response status is not 200 OK. The remote endpoint answered with an error (4xx/5xx) or a redirect loop, so the body is not the expected document.
Source
Thrown at oryx/fetcher/fetcher.go:172
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 {
return nil, err
}
return buf.Bytes(), nil
}
return io.ReadAll(res.Body)
}
View on GitHub (pinned to 4174065ffb)
Solutions
- Check the returned status code and fix the source URL or server-side error
- Ensure the endpoint requires no authentication, or configure credentials for the fetcher
- Retry later if the failure is a transient 5xx; the fetcher caches successful responses only
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at oryx/fetcher/fetcher.go:172 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- HTTP status errors: handling 4xx and 5xx responses — how to handle 4xx and 5xx responses properly.
AI-assisted analysis of ory/hydra@4174065ffb (2026-09-03).
Data as JSON: /api/errors/89dff0312bac4b04.
Report an issue: GitHub.