lionsoul2014/ip2region · error
invalid cache policy `%s`, options: file/vectorIndex/content
Error message
invalid cache policy `%s`, options: file/vectorIndex/content
What it means
Go CLI helper: the cachePolicy switch fell through to default — the string matches none of nil/file, vectorIndex, content; the message enumerates the only accepted values.
Source
Thrown at binding/golang/main.go:120
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)
}
return xdb.NewWithBuffer(version, cBuff)
default:
return nil, fmt.Errorf("invalid cache policy `%s`, options: file/vectorIndex/content", cachePolicy)
}
}
func printHelp() {
fmt.Printf("ip2region xdb searcher\n")
fmt.Printf("%s [command] [command options]\n", os.Args[0])
fmt.Printf("Command: \n")
fmt.Printf(" search search input test\n")
fmt.Printf(" bench search bench test\n")
}
func testSearch() {
var err error
var help = ""
var v4DbPath, v4CachePolicy = "", "vectorIndex"
var v6DbPath, v6CachePolicy = "", "vectorIndex"
for i := 2; i < len(os.Args); i++ {
r := os.Args[i]View on GitHub (pinned to c1a1fc7d59)
Solutions
- Pass one of: file, vectorIndex, or content
- Normalize/validate the policy string before calling createSearcher
- Treat empty policy as 'file' at the CLI layer
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at binding/golang/main.go:120 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/7993b0b67ba98a3c.
Report an issue: GitHub.