{"record":{"id":"ccfbbb2bc0e0674e","repo":"projectdiscovery/subfinder","slug":"code-d-s","errorCode":null,"errorMessage":"code %d, %s","messagePattern":"code (.+?), (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/subscraping/sources/threatbook/threatbook.go","lineNumber":78,"sourceCode":"\t\t\ts.errors++\n\t\t\tsession.DiscardHTTPResponse(resp)\n\t\t\treturn\n\t\t}\n\n\t\tvar response threatBookResponse\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++\n\t\t\tsession.DiscardHTTPResponse(resp)\n\t\t\treturn\n\t\t}\n\t\tsession.DiscardHTTPResponse(resp)\n\n\t\tif response.ResponseCode != 0 {\n\t\t\tresults <- subscraping.Result{\n\t\t\t\tSource: s.Name(), Type: subscraping.Error,\n\t\t\t\tError: fmt.Errorf(\"code %d, %s\", response.ResponseCode, response.VerboseMsg),\n\t\t\t}\n\t\t\ts.errors++\n\t\t\treturn\n\t\t}\n\n\t\ttotal, err := strconv.ParseInt(response.Data.SubDomains.Total, 10, 64)\n\t\tif err != nil {\n\t\t\tresults <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err}\n\t\t\ts.errors++\n\t\t\treturn\n\t\t}\n\n\t\tif total > 0 {\n\t\t\tfor _, subdomain := range response.Data.SubDomains.Data {\n\t\t\t\tselect {\n\t\t\t\tcase <-ctx.Done():\n\t\t\t\t\treturn\n\t\t\t\tcase results <- subscraping.Result{Source: s.Name(), Type: subscraping.Subdomain, Value: subdomain}:","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/projectdiscovery/subfinder/blob/7a0b91f0fac01b62c65328bd771a3560ae611d6a/pkg/subscraping/sources/threatbook/threatbook.go#L60-L96","documentation":"The threatbook source raises this when the ThreatBook API response carries a non-zero ResponseCode. ThreatBook encodes request failures (auth, quota, bad params) in this code with a human-readable VerboseMsg, which the library formats as \"code %d, %s\".","triggerScenarios":"Any ThreatBook API call that returns JSON with response_code != 0 — invalid/expired API key, daily quota exhausted, or an unsupported/invalid query parameter.","commonSituations":"Free-tier ThreatBook key out of daily quota; key not provisioned for the subdomain endpoint; deprecated API version producing param errors.","solutions":["Look up the numeric code in ThreatBook's API docs and address the stated cause in VerboseMsg.","Verify the THREATBOOK_API_KEY is valid and has quota remaining.","Retry after quota reset or upgrade the ThreatBook plan if code indicates limit exhaustion."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if os.Getenv(\"THREATBOOK_API_KEY\") == \"\" { return errors.New(\"THREATBOOK_API_KEY not set\") }","typeGuard":null,"tryCatchPattern":"for r := range results {\n  if r.Type == subscraping.Error {\n    var code int\n    if n, _ := fmt.Sscanf(r.Error.Error(), \"code %d\", &code); n == 1 {\n      switch code {\n      case quotaCode:\n        // wait for reset or upgrade plan\n      case authCode:\n        // fix API key\n      }\n    }\n  }\n}","preventionTips":["Map ThreatBook response codes to actions before running large scans.","Track daily quota usage for your ThreatBook key.","Confirm the key is provisioned for the subdomain endpoint."],"tags":["network","api-error","threatbook","api-key"],"backgroundTag":"api-error-response","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"}