{"record":{"id":"89dff0312bac4b04","repo":"ory/hydra","slug":"expected-http-response-status-code-200-but-got-d","errorCode":null,"errorMessage":"expected http response status code 200 but got %d when fetching: %s","messagePattern":"expected http response status code 200 but got (.+?) when fetching: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oryx/fetcher/fetcher.go","lineNumber":172,"sourceCode":"\t\t\t\ttoCache := make([]byte, len(b))\n\t\t\t\tcopy(toCache, b)\n\t\t\t\tf.cache.SetWithTTL(cacheKey[:], toCache, int64(len(toCache)), f.ttl)\n\t\t\t}\n\t\t}()\n\t}\n\n\treq, err := retryablehttp.NewRequestWithContext(ctx, http.MethodGet, source, nil)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"new request: %s\", redactedSource(source))\n\t}\n\tres, err := f.hc.Do(req)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, redactedSource(source))\n\t}\n\tdefer res.Body.Close()\n\n\tif res.StatusCode != http.StatusOK {\n\t\treturn nil, errors.Errorf(\"expected http response status code 200 but got %d when fetching: %s\", res.StatusCode, redactedSource(source))\n\t}\n\n\tif f.limit > 0 {\n\t\tvar buf bytes.Buffer\n\t\tn, err := io.Copy(&buf, io.LimitReader(res.Body, f.limit+1))\n\t\tif n > f.limit {\n\t\t\treturn nil, bytes.ErrTooLarge\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn buf.Bytes(), nil\n\t}\n\treturn io.ReadAll(res.Body)\n}\n","sourceCodeStart":154,"sourceCodeEnd":188,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/fetcher/fetcher.go#L154-L188","documentation":"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.","triggerScenarios":"Thrown at oryx/fetcher/fetcher.go:172 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4174065ffb052799890f7480f5360a877a67ffc1","analyzedAt":"2026-09-03T14:52:41.581Z","contentChangedAt":"2026-09-03T14:52:41.581Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}