{"record":{"id":"89000f6bbad8b882","repo":"sundowndev/phoneinfoga","slug":"errorresponse-message","errorCode":null,"errorMessage":"errorResponse.Message","messagePattern":"errorResponse\\.Message","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"lib/remote/suppliers/numverify.go","lineNumber":89,"sourceCode":"\treq, _ := http.NewRequest(\"GET\", url, nil)\n\treq.Header.Set(\"Apikey\", r.apiKey)\n\n\tresponse, err := client.Do(req)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer response.Body.Close()\n\n\t// Fill the response with the data from the JSON\n\tvar result NumverifyValidateResponse\n\n\tif response.StatusCode >= 400 {\n\t\terrorResponse := NumverifyErrorResponse{}\n\t\tif err := json.NewDecoder(response.Body).Decode(&errorResponse); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn nil, errors.New(errorResponse.Message)\n\t}\n\n\t// Use json.Decode for reading streams of JSON data\n\tif err := json.NewDecoder(response.Body).Decode(&result); err != nil {\n\t\treturn nil, err\n\t}\n\n\tres = &NumverifyValidateResponse{\n\t\tValid:               result.Valid,\n\t\tNumber:              result.Number,\n\t\tLocalFormat:         result.LocalFormat,\n\t\tInternationalFormat: result.InternationalFormat,\n\t\tCountryPrefix:       result.CountryPrefix,\n\t\tCountryCode:         result.CountryCode,\n\t\tCountryName:         result.CountryName,\n\t\tLocation:            result.Location,\n\t\tCarrier:             result.Carrier,\n\t\tLineType:            result.LineType,","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/sundowndev/phoneinfoga/blob/55807b05b753dab7bc6fe67403ca385668dda179/lib/remote/suppliers/numverify.go#L71-L107","documentation":"numverify.ValidateNumber treats any HTTP status >= 400 as failure: it decodes the JSON body into NumverifyErrorResponse and surfaces the API's 'message' field as a Go error. The text you see is whatever numverify's API returned (e.g. invalid key, missing function, rate limit).","triggerScenarios":"The numverify API responds with 400/401/etc — invalid or missing API key, free-plan HTTPS restriction, wrong endpoint, or account quota exhausted — and the error body contains a message field.","commonSituations":"Using an invalid/expired numverify access key, using HTTPS on the numverify free plan (which only allows HTTP), or exhausting the 250 free monthly API calls.","solutions":["Check the message text returned: it usually states 'invalid access key', 'missing access key', etc.","Verify your NUMVERIFY_API_KEY is correct and active in the numverify dashboard","On the free plan, ensure requests are not forced to HTTPS (free tier blocks https)","Check monthly API usage; upgrade plan or wait for quota reset if 250 calls exceeded"],"exampleFix":"// before\nclient.Request().SetApiKey(\"wrongkey\")   // -> error: invalid access key\n// after\nclient.Request().SetApiKey(os.Getenv(\"NUMVERIFY_API_KEY\"))   // valid key","handlingStrategy":"try-catch","validationCode":"if resp.StatusCode >= 400 {\n    // handle before decoding success payload\n}\n// pre-call: ensure key present\nif os.Getenv(\"NUMVERIFY_API_KEY\") == \"\" { return errors.New(\"NUMVERIFY_API_KEY missing\") }","typeGuard":"func isNumverifyAPIError(err error) bool {\n    msg := err.Error()\n    return strings.Contains(msg, \"access key\") || strings.Contains(msg, \"quota\")\n}","tryCatchPattern":"res, err := supplier.ValidateNumber(n)\nif err != nil {\n    if isNumverifyAPIError(err) {\n        log.Errorf(\"numverify rejected the request: %v\", err)\n        return fallbackScanner(n)\n    }\n    return err\n}","preventionTips":["Keep the numverify key valid and monitor monthly usage (250 free calls)","Avoid HTTPS on the free plan (free tier blocks https)","Check HTTP status before decoding success payloads in custom integrations","Implement a fallback scanner for numverify outages/quota exhaustion"],"tags":["numverify","http-error","api-response","third-party"],"backgroundTag":"upstream-api-error-response","analyzedSha":"55807b05b753dab7bc6fe67403ca385668dda179","analyzedAt":"2026-09-03T13:37:27.908Z","contentChangedAt":"2026-09-03T13:37:27.908Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}