{"record":{"id":"6a670a50463e8fd7","repo":"sundowndev/phoneinfoga","slug":"country-code-d-wasn-t-recognized","errorCode":null,"errorMessage":"country code +%d wasn't recognized","messagePattern":"country code \\+(.+?) wasn't recognized","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/remote/suppliers/ovh.go","lineNumber":52,"sourceCode":"// OVHScannerResponse is the OVH scanner response\ntype OVHScannerResponse struct {\n\tFound       bool\n\tNumberRange string\n\tCity        string\n\tZipCode     string\n}\n\ntype OVHSupplier struct{}\n\nfunc NewOVHSupplier() *OVHSupplier {\n\treturn &OVHSupplier{}\n}\n\nfunc (s *OVHSupplier) Search(num number.Number) (*OVHScannerResponse, error) {\n\tcountryCode := strings.ToLower(num.Country)\n\n\tif countryCode == \"\" {\n\t\treturn nil, fmt.Errorf(\"country code +%d wasn't recognized\", num.CountryCode)\n\t}\n\n\t// Build the request\n\tresponse, err := http.Get(fmt.Sprintf(\"https://api.ovh.com/1.0/telephony/number/detailedZones?country=%s\", countryCode))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer response.Body.Close()\n\n\tif response.StatusCode >= 400 {\n\t\tvar result OVHAPIErrorResponse\n\t\terr = json.NewDecoder(response.Body).Decode(&result)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn nil, errors.New(result.Message)\n\t}\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/sundowndev/phoneinfoga/blob/55807b05b753dab7bc6fe67403ca385668dda179/lib/remote/suppliers/ovh.go#L34-L70","documentation":"OVHSupplier.Search requires num.Country (used as the country code in the OVH API URL) to be non-empty; it lowercases it and appends it to the detailedZones endpoint. If num.CountryCode is set but num.Country is empty, it returns this error, since the numeric country code alone cannot produce the alphabetical country parameter the OVH API expects.","triggerScenarios":"Calling Search on a number.Number whose Country field is \"\" (unparsed/missing) — the message reports the numeric CountryCode that could not be mapped, e.g. 'country code +33 wasn't recognized'.","commonSituations":"Number parsed by a library that fills CountryCode but not the ISO Country field; caller constructed number.Number manually with only CountryCode; upstream parsing failed silently and Country was never normalized to an ISO code like 'fr' or 'ca'.","solutions":["Ensure num.Country is populated with an ISO-2 country code (e.g. 'FR') before calling Search","Populate Country from CountryCode via a lookup table or library (e.g. 'github.com/itchyny/goqi' / libphonenumber's GetRegionCodeForCountryCode) at parse time","Validate the number before calling: skip/log numbers with empty Country instead of calling Search","If the number is genuinely unparseable, fall back to another supplier or mark the scan result as unknown"],"exampleFix":"// before\nres, err := supplier.Search(number.Number{CountryCode: 33})\n// after\nif num.Country == \"\" {\n    num.Country = regionCodeFor(num.CountryCode) // e.g. 33 -> \"FR\"\n}\nres, err := supplier.Search(num)","handlingStrategy":"validation","validationCode":"if num.Country == \"\" {\n    return fmt.Errorf(\"cannot search OVH: number %d has no country\", num.CountryCode)\n}","typeGuard":"func hasCountry(num number.Number) bool {\n    return num.Country != \"\"\n}","tryCatchPattern":"res, err := supplier.Search(num)\nif err != nil {\n    if strings.Contains(err.Error(), \"wasn't recognized\") {\n        log.Warnf(\"skipping +%d: missing country code\", num.CountryCode)\n        return nil, nil // skip this number\n    }\n    return nil, err\n}","preventionTips":["Always populate Country (ISO-2 code) when parsing numbers, not just CountryCode","Run a pre-scan validation pass that drops or repairs numbers missing Country","Normalize country input (TrimSpace + strings.ToLower) before constructing number.Number","Prefer a parsing library (e.g. libphonenumber) that reliably sets the region code"],"tags":["go","ovh","validation","phone-number"],"backgroundTag":"missing-required-argument","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"}