lionsoul2014/ip2region · error
failed to detect IP version from `%s`: %s
Error message
failed to detect IP version from `%s`: %s
What it means
Go CLI helper: xdb.VersionFromHeader rejected the header — the structure version is not 2.0/3.0 or the ipVersion field is unknown, so the IP family of the database cannot be auto-detected.
Source
Thrown at binding/golang/main.go:99
defer handle.Close()
// verify the xdb file
// @Note: do NOT call it every time you create a searcher since this will slow down the search response.
// @see the util.Verify function for details.
err = xdb.Verify(handle)
if err != nil {
return nil, fmt.Errorf("xdb verify: %w", err)
}
// auto-detect the ip version from the xdb header
header, err := xdb.LoadHeader(handle)
if err != nil {
return nil, fmt.Errorf("failed to load header from `%s`: %s", dbPath, err)
}
version, err := xdb.VersionFromHeader(header)
if err != nil {
return nil, fmt.Errorf("failed to detect IP version from `%s`: %s", dbPath, err)
}
switch cachePolicy {
case "nil", "file":
return xdb.NewWithFileOnly(version, dbPath)
case "vectorIndex":
vIndex, err := xdb.LoadVectorIndexFromFile(dbPath)
if err != nil {
return nil, fmt.Errorf("failed to load vector index from `%s`: %w", dbPath, err)
}
return xdb.NewWithVectorIndex(version, dbPath, vIndex)
case "content":
cBuff, err := xdb.LoadContentFromFile(dbPath)
if err != nil {
return nil, fmt.Errorf("failed to load content from '%s': %w", dbPath, err)
}
View on GitHub (pinned to c1a1fc7d59)
Solutions
- Use a valid xdb whose header carries a recognized structure and ip version
- Regenerate the database with the current maker
- Manually construct the searcher with an explicit version if the header is known-good but nonstandard
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at binding/golang/main.go:99 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of lionsoul2014/ip2region@c1a1fc7d59 (2026-09-02).
Data as JSON: /api/errors/30cb9f4a2dbecc7b.
Report an issue: GitHub.