{"record":{"id":"30260a657c733c6c","repo":"lionsoul2014/ip2region","slug":"invalid-cache-policy-options-file-vectorindex-co","errorCode":null,"errorMessage":"invalid cache policy, options: file/vectorIndex/content","messagePattern":"invalid cache policy, options: file/vectorIndex/content","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"binding/nginx/src/ngx_http_ip2region_module.c","lineNumber":210,"sourceCode":"            if(ngx_http_ip2region_is_absolute_path(db_name) != NGX_OK) {\n                free(db_path);\n            }\n            return NGX_CONF_ERROR;\n        }\n\n        err = xdb_new_with_buffer(xdb_version, &ip2region_searcher->searcher, ip2region_searcher->c_buffer);\n        xdb_free_header((void *)header);\n        if (err != 0) {\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               \"failed to create content cached searcher: %s\", db_path);\n            xdb_free_content((void *)ip2region_searcher->c_buffer);\n            if(ngx_http_ip2region_is_absolute_path(db_name) != NGX_OK) {\n                free(db_path);\n            }\n            return NGX_CONF_ERROR;\n        }\n    } else {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           \"invalid cache policy, options: file/vectorIndex/content\");\n        xdb_free_header((void *)header);\n        if(ngx_http_ip2region_is_absolute_path(db_name) != NGX_OK) {\n            free(db_path);\n        }\n        return NGX_CONF_ERROR;\n    }\n\n    if(ngx_http_ip2region_is_absolute_path(db_name) != NGX_OK) {\n        free(db_path);\n    }\n\n    return (char *)ip2region_searcher;\n}\n\n\nstatic char *\nngx_http_ip2region_init(ngx_conf_t *cf, ngx_command_t *cmd,","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/nginx/src/ngx_http_ip2region_module.c#L192-L228","documentation":"The ip2region_cache_policy directive received a value that is not one of the three supported strings: \"file\", \"vectorIndex\", or \"content\". The module falls into the else branch, frees resources, and rejects the configuration.","triggerScenarios":"Any misspelled or wrong-case value in nginx.conf, e.g. `ip2region_cache_policy Content;`, `content ` with trailing whitespace via variable, `vector_index`, `none`, or an empty value.","commonSituations":"Typos when copying examples from docs for other bindings (some bindings use different policy names); Nginx variable interpolation yielding an unexpected string; case sensitivity mistakes.","solutions":["Set the policy to exactly one of: file, vectorIndex, content (lowercase, no quotes/whitespace).","Fix the typo — e.g. vector_index -> vectorIndex, Content -> content.","Run `nginx -t` to validate the config before reload.","Check the README of the nginx binding for the exact accepted values."],"exampleFix":"# before\nip2region_cache_policy vector_index;\n# after\nip2region_cache_policy vectorIndex;","handlingStrategy":"validation","validationCode":"# nginx.conf lint before reload\ncase \"$(awk '/ip2region_cache_policy/{gsub(\";\",\"\");print $2}' nginx.conf)\" in\n  file|vectorIndex|content) echo OK ;;\n  *) echo \"invalid ip2region_cache_policy (use file|vectorIndex|content)\"; exit 1 ;;\nesac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Memorize the three accepted values: file, vectorIndex, content — exact lowercase.","Run `nginx -t` as a CI gate for every config change.","Copy config snippets from the nginx binding's own README, not other-language docs.","Avoid trailing whitespace/variables feeding the directive."],"tags":["nginx","config","validation","cache-policy"],"backgroundTag":"invalid-config-value","analyzedSha":"c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1","analyzedAt":"2026-09-02T16:58:39.988Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}