lionsoul2014/ip2region · error

xdb verify: %w

Error message

xdb verify: %w

What it means

Go CLI helper: xdb.Verify failed while validating the xdb file's internal structure (header/index checksums) before creating a searcher; the wrapped error describes the specific integrity violation.

Source

Thrown at binding/golang/main.go:88

	}

	return service.NewIp2Region(v4Config, v6Config)
}

func createSearcher(dbPath string, cachePolicy string) (*xdb.Searcher, error) {
	handle, err := os.OpenFile(dbPath, os.O_RDONLY, 0600)
	if err != nil {
		return nil, fmt.Errorf("open xdb file `%s`: %w", dbPath, err)
	}

	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)

View on GitHub (pinned to c1a1fc7d59)

Solutions

  1. Re-generate or re-download a non-corrupted xdb file
  2. Check the file was fully transferred (compare size/hash)
  3. Skip verify only if you accept the risk; verification is deliberately slow and optional in production paths
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at binding/golang/main.go:88 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/914e5c85882260a5. Report an issue: GitHub.