lionsoul2014/ip2region · error

invalid cache policy name `%s`

Error message

invalid cache policy name `%s`

What it means

Go service package: CachePolicyFromName hit its default case — the lowercased name matches none of the accepted cache policy aliases (file/nocache, vectorindex/vindex/vindexcache, content/buffercache).

Source

Thrown at binding/golang/service/config.go:36

// @Author Lion <chenxin619315@gmail.com>
// @Date   2025/12/03

const (
	NoCache     = 0
	VIndexCache = 1
	BufferCache = 2
)

func CachePolicyFromName(name string) (int, error) {
	switch strings.ToLower(name) {
	case "file", "nocache":
		return NoCache, nil
	case "vectorindex", "vindex", "vindexcache":
		return VIndexCache, nil
	case "content", "buffercache":
		return BufferCache, nil
	default:
		return NoCache, fmt.Errorf("invalid cache policy name `%s`", name)
	}
}

type Config struct {
	cachePolicy int
	ipVersion   *xdb.Version

	// xdb file path
	xdbPath string
	header  *xdb.Header

	// buffers
	vIndex  []byte
	cBuffer []byte

	searchers int
}

View on GitHub (pinned to c1a1fc7d59)

Solutions

  1. Use an accepted policy name or alias
  2. Validate policy names in configuration before constructing the service
  3. Map unknown values to a documented default rather than passing them through
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at binding/golang/service/config.go:36 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/78c7b8b370f01e89. Report an issue: GitHub.