{"record":{"id":"d8c6eb19c8cdc19e","repo":"projectdiscovery/subfinder","slug":"unexpected-status-code-d","errorCode":null,"errorMessage":"unexpected status code %d","messagePattern":"unexpected status code (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/subscraping/sources/digitalyama/digitalyama.go","lineNumber":77,"sourceCode":"\t\t}\n\t\tdefer func() {\n\t\t\tif err := resp.Body.Close(); err != nil {\n\t\t\t\tresults <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err}\n\t\t\t\ts.errors++\n\t\t\t}\n\t\t}()\n\n\t\tif resp.StatusCode != 200 {\n\t\t\tvar errResponse struct {\n\t\t\t\tDetail []struct {\n\t\t\t\t\tLoc  []string `json:\"loc\"`\n\t\t\t\t\tMsg  string   `json:\"msg\"`\n\t\t\t\t\tType string   `json:\"type\"`\n\t\t\t\t} `json:\"detail\"`\n\t\t\t}\n\t\t\terr = jsoniter.NewDecoder(resp.Body).Decode(&errResponse)\n\t\t\tif err != nil {\n\t\t\t\tresults <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: fmt.Errorf(\"unexpected status code %d\", resp.StatusCode)}\n\t\t\t\ts.errors++\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif len(errResponse.Detail) > 0 {\n\t\t\t\terrMsg := errResponse.Detail[0].Msg\n\t\t\t\tresults <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: fmt.Errorf(\"%s (code %d)\", errMsg, resp.StatusCode)}\n\t\t\t} else {\n\t\t\t\tresults <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: fmt.Errorf(\"unexpected status code %d\", resp.StatusCode)}\n\t\t\t}\n\t\t\ts.errors++\n\t\t\treturn\n\t\t}\n\n\t\tvar response digitalYamaResponse\n\t\terr = jsoniter.NewDecoder(resp.Body).Decode(&response)\n\t\tif err != nil {\n\t\t\tresults <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err}\n\t\t\ts.errors++","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/projectdiscovery/subfinder/blob/7a0b91f0fac01b62c65328bd771a3560ae611d6a/pkg/subscraping/sources/digitalyama/digitalyama.go#L59-L95","documentation":"The Digitalyama source, when the API responds with a non-success status code, tries to decode a structured error body ({detail: [{msg, type}]}). If that decode itself fails, it falls back to emitting fmt.Errorf(\"unexpected status code %d\", resp.StatusCode) — a plain HTTP status error.","triggerScenarios":"Digitalyama API returns an unexpected status code whose body is not the documented error shape (undecodable JSON) — auth failures, rate limiting, outages, proxies returning HTML error pages.","commonSituations":"Invalid/missing Digitalyama API key; hitting request quotas; a proxy or WAF intercepting the request and returning non-JSON; Digitalyama service disruption.","solutions":["Check/fix the Digitalyama API key in the provider config","Confirm the status code context: 401/403 → credentials, 429 → backoff and slow down, 5xx → retry later","Ensure no proxy/WAF is altering responses for the endpoint","Retry with backoff or disable the digitalyama source temporarily"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"for result := range results {\n    if result.Type == subscraping.Error {\n        gologger.Warning().Msgf(\"digitalyama: %v\", result.Error)\n        continue\n    }\n    // process result\n}","preventionTips":["Keep the Digitalyama API key valid","Back off on 429s; retry on 5xx","Ensure no proxy/WAF rewrites responses","Handle Error-type results per source"],"tags":["digitalyama","http","api"],"backgroundTag":"unexpected-http-status","analyzedSha":"7a0b91f0fac01b62c65328bd771a3560ae611d6a","analyzedAt":"2026-09-06T23:52:02.109Z","contentChangedAt":"2026-09-06T23:52:02.109Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}