{"record":{"id":"43f1e015a36db1e2","repo":"nats-io/nats-server","slug":"template-operation-in-q-q-is-not-defined","errorCode":null,"errorMessage":"template operation in %q: %q is not defined","messagePattern":"template operation in %q: %q is not defined","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/auth.go","lineNumber":585,"sourceCode":"\t\t\t\t\t}\n\t\t\t\t\ttagPrefix := fmt.Sprintf(\"%s:\", strings.ToLower(match[1]))\n\t\t\t\t\tvar valueList []string\n\t\t\t\t\tfor _, tag := range tags {\n\t\t\t\t\t\tif strings.HasPrefix(tag, tagPrefix) {\n\t\t\t\t\t\t\ttagValue := strings.TrimPrefix(tag, tagPrefix)\n\t\t\t\t\t\t\tvalueList = append(valueList, tagValue)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif len(valueList) != 0 {\n\t\t\t\t\t\tvalues[tokenNum] = valueList\n\t\t\t\t\t} else if failOnBadSubject {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"generated invalid subject %q: %q is not defined\", list[i], match[1])\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// generate an invalid subject?\n\t\t\t\t\t\tvalues[tokenNum] = []string{\" \"}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, fmt.Errorf(\"template operation in %q: %q is not defined\", list[i], op)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !hasTags {\n\t\t\t\tsubj := list[i]\n\t\t\t\tfor idx, m := range srcs {\n\t\t\t\t\tsubj = strings.Replace(subj, m, values[idx][0], -1)\n\t\t\t\t}\n\t\t\t\tif IsValidSubject(subj) {\n\t\t\t\t\temittedList = append(emittedList, subj)\n\t\t\t\t} else if failOnBadSubject {\n\t\t\t\t\treturn nil, fmt.Errorf(\"generated invalid subject\")\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\texpCount := 1\n\t\t\t\tfor _, v := range values {\n\t\t\t\t\tif len(v) == 0 {\n\t\t\t\t\t\texpCount = 0\n\t\t\t\t\t\tbreak","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/auth.go#L567-L603","documentation":"A mustache-style template in a permission subject referenced an operation that is not recognized by the expander (only known operations like account-tag are supported), so the subject cannot be expanded at all.","triggerScenarios":"Thrown at server/auth.go:585 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a supported template operation such as {{account-tag:name}}","Fix the typo in the template token","Remove unsupported template syntax from the permission subject"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}