{"record":{"id":"2b7040589ec4895c","repo":"1Panel-dev/1Panel","slug":"no-enough-parameter-for-location","errorCode":null,"errorMessage":"no enough parameter for location","messagePattern":"no enough parameter for location","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/utils/nginx/components/location.go","lineNumber":45,"sourceCode":"\tAllowMethods     string\n\tAllowHeaders     string\n\tAllowOrigins     string\n\tAllowCredentials bool\n\tPreflight        bool\n}\n\nfunc (l *Location) GetCodeBlock() string {\n\treturn \"\"\n}\n\nfunc NewLocation(directive IDirective) *Location {\n\tlocation := &Location{\n\t\tModifier: \"\",\n\t\tMatch:    \"\",\n\t}\n\tdirectives := make([]IDirective, 0)\n\tif len(directive.GetParameters()) == 0 {\n\t\tpanic(\"no enough parameter for location\")\n\t}\n\tfor _, dir := range directive.GetBlock().GetDirectives() {\n\t\tdirectives = append(directives, dir)\n\t\tparams := dir.GetParameters()\n\t\tswitch dir.GetName() {\n\t\tcase \"proxy_pass\":\n\t\t\tlocation.ProxyPass = params[0]\n\t\tcase \"proxy_set_header\":\n\t\t\tif params[0] == \"Host\" {\n\t\t\t\tlocation.Host = params[1]\n\t\t\t}\n\t\tcase \"proxy_cache\":\n\t\t\tlocation.Cache = true\n\t\tcase \"if\":\n\t\t\tif params[0] == \"(\" && params[1] == \"$uri\" && params[2] == \"~*\" {\n\t\t\t\tdirs := dir.GetBlock().GetDirectives()\n\t\t\t\tfor _, di := range dirs {\n\t\t\t\t\tif di.GetName() == \"expires\" {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/1Panel-dev/1Panel/blob/5ac7c808815b0691009cd390414f03471312262f/agent/utils/nginx/components/location.go#L27-L63","documentation":"Panic in NewLocation when converting a parsed 'location' directive whose parameter list is empty — the parser expected at least a match string (e.g. '/' or '= /exact'). It indicates a malformed nginx config block like 'location { ... }' being processed by the 1Panel nginx AST layer.","triggerScenarios":"Parsing a server block containing a bare 'location' with no argument; the parser hands the directive to wrapLocation and NewLocation immediately panics on len(directive.GetParameters())==0.","commonSituations":"User hand-edited a website config and deleted the path after 'location'; a template rendered an empty match variable; a config generator bug emitted 'location {'.","solutions":["Find the offending block: grep -rn '^\\s*location\\s*{' /opt/1panel/apps/openresty/openresty/conf -r and add the missing match ('location / {')","Fix the template/variable that produced the empty location so it always emits a path","Reload/re-parse the config through 1Panel to confirm no panic"],"exampleFix":"# before\nlocation {\n  proxy_pass http://up;\n}\n# after\nlocation / {\n  proxy_pass http://up;\n}","handlingStrategy":"validation","validationCode":"grep -rnE '^\\s*location\\s*\\{' /opt/1panel/apps/openresty/openresty/conf 2>/dev/null  # must be empty before parsing via 1Panel","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run nginx -t after every manual config edit before 1Panel re-parses the file","Template generators should always emit a match token for location blocks"],"tags":["nginx","parser","go","panic","config"],"backgroundTag":null,"analyzedSha":"5ac7c808815b0691009cd390414f03471312262f","analyzedAt":"2026-08-15T14:02:06.953Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}