{"record":{"id":"e12359a54c446c50","repo":"lionsoul2014/ip2region","slug":"expand-s-s","errorCode":null,"errorMessage":"Expand(`%s`): %s","messagePattern":"Expand\\(`(.+?)`\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"binding/golang/main.go","lineNumber":50,"sourceCode":"\t_, err = os.Stat(xdbPath)\n\tif err != nil {\n\t\treturn \"\", nil\n\t}\n\n\t// fmt.Printf(\"xdbPath=%s\\n\", xdbPath)\n\treturn xdbPath, nil\n}\n\nfunc createService(v4XdbPath string, v4CachePolicy string, v6XdbPath string, v6CachePolicy string) (*service.Ip2Region, error) {\n\t// try to create v4 config\n\tv4CPolicy, err := service.CachePolicyFromName(v4CachePolicy)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parse v4 cache policy: %w\", err)\n\t}\n\n\tv4DbPath, err := homedir.Expand(v4XdbPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Expand(`%s`): %s\", v4XdbPath, err)\n\t}\n\tv4Config, err := service.NewV4Config(v4CPolicy, v4DbPath, 1)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"NewV4Config: %w\", err)\n\t}\n\n\t// try to create v6 config\n\tv6Policy, err := service.CachePolicyFromName(v6CachePolicy)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parse v6 cache policy: %w\", err)\n\t}\n\n\tv6DbPath, err := homedir.Expand(v6XdbPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Expand(`%s`): %s\", v6XdbPath, err)\n\t}\n\tv6Config, err := service.NewV6Config(v6Policy, v6DbPath, 1)\n\tif err != nil {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/golang/main.go#L32-L68","documentation":"Go service factory: homedir.Expand failed while resolving a leading ~ in the v4 xdb path (e.g. $HOME unset or malformed path), so the absolute db path could not be derived.","triggerScenarios":"Thrown at binding/golang/main.go:50 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use an absolute path for the v4 xdb file","Ensure HOME is set for the running user when using ~ paths","Validate the expanded path exists before creating the service"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1","analyzedAt":"2026-09-02T16:58:39.988Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}