owasp-amass/amass · error
address is not a valid UTF-8 string
Error message
address is not a valid UTF-8 string
What it means
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.
Source
Thrown at internal/libpostal/cgo_specific.go:54
func getDefaultParserOptions() ParserOptions {
return ParserOptions{
Language: "",
Country: "",
}
}
func ParseAddress(ctx context.Context, address string) ([]ParsedComponent, error) {
return ParseAddressOptions(ctx, address, parserDefaultOptions)
}
func ParseAddressOptions(ctx context.Context, address string, options ParserOptions) ([]ParsedComponent, error) {
if !postalLibAvailable {
return nil, errors.New(ErrPostalLibNotAvailable)
}
if !utf8.ValidString(address) {
return nil, errors.New("address is not a valid UTF-8 string")
}
postalLock.Lock()
defer postalLock.Unlock()
cAddress := C.CString(address)
defer C.free(unsafe.Pointer(cAddress))
cOptions := C.libpostal_get_address_parser_default_options()
if options.Language != "" {
cLanguage := C.CString(options.Language)
defer C.free(unsafe.Pointer(cLanguage))
cOptions.language = cLanguage
}
if options.Country != "" {
cCountry := C.CString(options.Country)View on GitHub (pinned to 79299dce87)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/libpostal/cgo_specific.go:54 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06).
Data as JSON: /api/errors/acb2e23ca7742cea.
Report an issue: GitHub.