{"record":{"id":"06698881fdb5913d","repo":"nginx/nginx","slug":"ngx-log-emerg-066988","errorCode":"NGX_LOG_EMERG","errorMessage":"invalid variable name \\\"%V\\\"","messagePattern":"invalid variable name \\\\\"%V\\\\\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/http/modules/ngx_http_auth_request_module.c","lineNumber":401,"sourceCode":"\n    return NGX_CONF_OK;\n}\n\n\nstatic char *\nngx_http_auth_request_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)\n{\n    ngx_http_auth_request_conf_t *arcf = conf;\n\n    ngx_str_t                         *value;\n    ngx_http_variable_t               *v;\n    ngx_http_auth_request_variable_t  *av;\n    ngx_http_compile_complex_value_t   ccv;\n\n    value = cf->args->elts;\n\n    if (value[1].data[0] != '$') {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           \"invalid variable name \\\"%V\\\"\", &value[1]);\n        return NGX_CONF_ERROR;\n    }\n\n    value[1].len--;\n    value[1].data++;\n\n    if (arcf->vars == NGX_CONF_UNSET_PTR) {\n        arcf->vars = ngx_array_create(cf->pool, 1,\n                                      sizeof(ngx_http_auth_request_variable_t));\n        if (arcf->vars == NULL) {\n            return NGX_CONF_ERROR;\n        }\n    }\n\n    av = ngx_array_push(arcf->vars);\n    if (av == NULL) {\n        return NGX_CONF_ERROR;","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/nginx/nginx/blob/3f6f7824d4e2eb1ac37dec76683d525ac0ff521c/src/http/modules/ngx_http_auth_request_module.c#L383-L419","documentation":"The auth_request_set directive registers a variable to be filled from the auth subrequest; its first argument must be a variable reference starting with '$'. If it does not, nginx logs EMERG during configuration parsing and aborts. The '$' is stripped and the remainder is compiled as the variable name.","triggerScenarios":"Writing 'auth_request_set authuser $upstream_http_x_user;' (missing $), or quoting that drops the dollar sign; copy-paste from docs where $ was rendered literally.","commonSituations":"First-time auth_request users assuming the argument is a plain name; templating systems (Helm, envsubst) consuming $ - in templates use $$ to escape.","solutions":["Prefix the first argument with $: auth_request_set $authuser $upstream_http_x_user;","Run 'nginx -t' to catch it before reload.","In envsubst/Helm templates escape the dollar as $$ so it survives rendering."],"exampleFix":"# before\nauth_request_set authuser $upstream_http_x_user;\n\n# after\nauth_request_set $authuser $upstream_http_x_user;","handlingStrategy":"validation","validationCode":"nginx -t 2>&1 | grep 'invalid variable name'   # fail the pipeline if present\n# reject auth_request_set lines lacking the dollar sign before deploy\ngrep -nE 'auth_request_set\\s+[^$]' /etc/nginx/**/*.conf","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write auth_request_set $name value;.","Escape dollars in envsubst/Helm templates ($$) so rendering does not strip them.","Run 'nginx -t' as a CI gate for every config change."],"tags":["config","auth-request","variable","startup","nginx-emerg"],"backgroundTag":"invalid-variable-name","analyzedSha":"3f6f7824d4e2eb1ac37dec76683d525ac0ff521c","analyzedAt":"2026-08-22T03:09:46.447Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}