{"record":{"id":"8e273b4e016fce66","repo":"Netflix/chaosmonkey","slug":"unexpected-response-code-d-from-s","errorCode":null,"errorMessage":"unexpected response code (%d) from %s","messagePattern":"unexpected response code \\((.+?)\\) from (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spinnaker/config.go","lineNumber":43,"sourceCode":"\n// Get implements chaosmonkey.Getter.Get\nfunc (s Spinnaker) Get(app string) (c *chaosmonkey.AppConfig, err error) {\n\t// avoid expanding the response to avoid unneeded load\n\turl := s.appURL(app) + \"?expand=false\"\n\tresp, err := s.client.Get(url)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"http get failed at %s\", url)\n\t}\n\n\tdefer func() {\n\t\tif cerr := resp.Body.Close(); cerr != nil && err == nil {\n\t\t\terr = errors.Wrapf(err, \"body close failed at %s\", url)\n\t\t}\n\t}()\n\n\t// should return a 200\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, errors.Errorf(\"unexpected response code (%d) from %s\", resp.StatusCode, url)\n\t}\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"body read failed at %s\", url)\n\t}\n\n\treturn fromJSON(body)\n}\n","sourceCodeStart":25,"sourceCodeEnd":53,"githubUrl":"https://github.com/Netflix/chaosmonkey/blob/eaa28fb761c0ebe8644d1333e5d164e9cc3071e9/spinnaker/config.go#L25-L53","documentation":"After a successful GET, Spinnaker.Get expects HTTP 200. Any other status code yields 'unexpected response code (%d) from %s'. This signals the gate responded but rejected or redirected the request rather than returning the app config payload.","triggerScenarios":"Spinnaker returns 404 (unknown app), 401/403 (missing/invalid auth), 5xx (gate internal error), or 3xx that the client did not follow for GET <appURL>?expand=false.","commonSituations":"Querying an app name that does not exist in Spinnaker; auth token/account credentials missing or expired; Spinnaker gate overloaded returning 502/503 from a proxy; app deleted after the monkey listed it.","solutions":["Check the reported status code: 404 means verify the app exists in Spinnaker; 401/403 means fix credentials/auth for the gate","Confirm the app name used in appURL matches Spinnaker's application name exactly","Inspect gate/proxy logs for 5xx causes (upstream Spinnaker health)","Ensure the HTTP client follows redirects if a 3xx is returned"],"exampleFix":"// caller-side guard\nresp, err := http.Get(gateURL + \"/applications/myapp?expand=false\")\nif err != nil { return err }\nif resp.StatusCode == http.StatusNotFound {\n    log.Println(\"app not found in spinnaker; skipping\")\n    return nil\n}\nif resp.StatusCode != http.StatusOK {\n    return fmt.Errorf(\"gate returned %d for %s\", resp.StatusCode, gateURL)\n}","handlingStrategy":"type-guard","validationCode":"resp, err := http.Get(gateURL + \"/applications/\" + app + \"?expand=false\")\nif err != nil { return err }\nswitch {\ncase resp.StatusCode == http.StatusNotFound:\n    return fmt.Errorf(\"app %s does not exist in Spinnaker\", app)\ncase resp.StatusCode == http.StatusUnauthorized || resp.StatusCode == http.StatusForbidden:\n    return errors.New(\"invalid or expired Spinnaker credentials\")\ncase resp.StatusCode != http.StatusOK:\n    return fmt.Errorf(\"gate returned %d\", resp.StatusCode)\n}","typeGuard":"func isNotFoundStatus(err error) bool {\n    m := regexp.MustCompile(`unexpected response code \\((\\d+)\\)`).FindStringSubmatch(err.Error())\n    return m != nil && m[1] == \"404\"\n}","tryCatchPattern":"cfg, err := getter.Get(app)\nif err != nil {\n    if isNotFoundStatus(err) {\n        log.Printf(\"skipping %s: not in Spinnaker\", app)\n        return nil // treat as non-fatal\n    }\n    return err\n}","preventionTips":["Keep Spinnaker credentials/tokens current and rotate before expiry","Verify app names against Spinnaker's application list before processing","Alert on 5xx rates from the gate and check proxy health","Confirm expected app inventory nightly to catch deleted apps early"],"tags":["go","http","spinnaker","http-status"],"backgroundTag":"unexpected-http-status","analyzedSha":"eaa28fb761c0ebe8644d1333e5d164e9cc3071e9","analyzedAt":"2026-09-03T17:04:39.020Z","contentChangedAt":"2026-09-03T17:04:39.020Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}