{"record":{"id":"acb2e23ca7742cea","repo":"owasp-amass/amass","slug":"address-is-not-a-valid-utf-8-string","errorCode":null,"errorMessage":"address is not a valid UTF-8 string","messagePattern":"address is not a valid UTF-8 string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/libpostal/cgo_specific.go","lineNumber":54,"sourceCode":"\nfunc getDefaultParserOptions() ParserOptions {\n\treturn ParserOptions{\n\t\tLanguage: \"\",\n\t\tCountry:  \"\",\n\t}\n}\n\nfunc ParseAddress(ctx context.Context, address string) ([]ParsedComponent, error) {\n\treturn ParseAddressOptions(ctx, address, parserDefaultOptions)\n}\n\nfunc ParseAddressOptions(ctx context.Context, address string, options ParserOptions) ([]ParsedComponent, error) {\n\tif !postalLibAvailable {\n\t\treturn nil, errors.New(ErrPostalLibNotAvailable)\n\t}\n\n\tif !utf8.ValidString(address) {\n\t\treturn nil, errors.New(\"address is not a valid UTF-8 string\")\n\t}\n\n\tpostalLock.Lock()\n\tdefer postalLock.Unlock()\n\n\tcAddress := C.CString(address)\n\tdefer C.free(unsafe.Pointer(cAddress))\n\n\tcOptions := C.libpostal_get_address_parser_default_options()\n\tif options.Language != \"\" {\n\t\tcLanguage := C.CString(options.Language)\n\t\tdefer C.free(unsafe.Pointer(cLanguage))\n\n\t\tcOptions.language = cLanguage\n\t}\n\n\tif options.Country != \"\" {\n\t\tcCountry := C.CString(options.Country)","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/internal/libpostal/cgo_specific.go#L36-L72","documentation":"ParseAddressOptions rejects the input because utf8.ValidString(address) is false: the address contains invalid UTF-8 byte sequences. The value must be passed to the C libpostal API as a C string, so non-UTF-8 input cannot be processed safely and the function bails out before acquiring the postal lock.","triggerScenarios":"Thrown at internal/libpostal/cgo_specific.go:54 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Sanitize or re-encode the input (e.g. strings.ToValidUTF8 with a replacement rune) before calling ParseAddress","Fix the upstream data source that produced the malformed bytes (file encoding, HTTP body decoding)","Reject the record early at ingestion with a clearer error that identifies the offending input"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}