{"record":{"id":"8b43023c256032f2","repo":"grafana/k6","slug":"wrong-status-code-d-for-s","errorCode":null,"errorMessage":"wrong status code (%d) for: %s","messagePattern":"wrong status code \\((.+?)\\) for: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/loader/loader.go","lineNumber":224,"sourceCode":"\tstartTime := time.Now()\n\tctx, cancel := context.WithTimeout(context.Background(), time.Minute)\n\tdefer cancel()\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tres, err := http.DefaultClient.Do(req) //nolint:gosec\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer func() { _ = res.Body.Close() }()\n\n\tif res.StatusCode != http.StatusOK {\n\t\tswitch res.StatusCode {\n\t\tcase http.StatusNotFound:\n\t\t\treturn nil, fmt.Errorf(\"not found: %s\", u)\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"wrong status code (%d) for: %s\", res.StatusCode, u)\n\t\t}\n\t}\n\n\tdata, err := io.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlogger.WithFields(logrus.Fields{\n\t\t\"url\": u,\n\t\t\"t\":   time.Since(startTime),\n\t\t\"len\": len(data),\n\t}).Debug(\"Fetched!\")\n\treturn data, nil\n}\n","sourceCodeStart":206,"sourceCodeEnd":240,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/loader/loader.go#L206-L240","documentation":"Raised in fetch when a remote module request returns any non-200 status other than 404 (e.g. 403 Forbidden, 500, 502). It means the server responded but refused or failed to serve the module. The at-fault inputs are the returned status code and the fetched URL.","triggerScenarios":"Thrown at internal/loader/loader.go:224 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the status code to identify the cause: 403 may require auth headers, 5xx indicates a server problem","Retry later for transient 5xx responses","Serve the module from a different mirror or host it locally","If auth is needed, use a URL/CDN that serves files publicly"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}