{"record":{"id":"cf10951266fe77f0","repo":"nats-io/nats-server","slug":"w-d","errorCode":null,"errorMessage":"%w: %d","messagePattern":"%w: %d","errorType":"validation","errorClass":"errPermTemplateExpansionLimit","httpStatus":null,"severity":"error","filePath":"server/auth.go","lineNumber":606,"sourceCode":"\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\n\t\t\t\t\t}\n\t\t\t\t\tif expCount > maxPermTemplateSubjectExpansions/len(v) {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"%w: %d\", errPermTemplateExpansionLimit, maxPermTemplateSubjectExpansions)\n\t\t\t\t\t}\n\t\t\t\t\texpCount *= len(v)\n\t\t\t\t}\n\t\t\t\tif len(emittedList) > maxPermTemplateSubjectExpansions-expCount {\n\t\t\t\t\treturn nil, fmt.Errorf(\"%w: %d\", errPermTemplateExpansionLimit, maxPermTemplateSubjectExpansions)\n\t\t\t\t}\n\t\t\t\ta := nArrayCartesianProduct(values...)\n\t\t\t\tfor _, aa := range a {\n\t\t\t\t\tsubj := list[i]\n\t\t\t\t\tfor j := 0; j < len(srcs); j++ {\n\t\t\t\t\t\tsubj = strings.Replace(subj, srcs[j], aa[j], -1)\n\t\t\t\t\t}\n\t\t\t\t\tif IsValidSubject(subj) {\n\t\t\t\t\t\temittedList = append(emittedList, subj)\n\t\t\t\t\t} else if failOnBadSubject {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"generated invalid subject\")\n\t\t\t\t\t}\n\t\t\t\t}","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/auth.go#L588-L624","documentation":"Same expansion-limit guard as the other errPermTemplateExpansionLimit sites: the running count of expanded subjects would exceed maxPermTemplateSubjectExpansions when multiplying value lists or appending the emitted list, so the error wraps the sentinel with the limit value.","triggerScenarios":"Thrown at server/auth.go:606 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce tag combinations used in templated subjects","Use more specific tag prefixes to shrink value lists","Replace wide templates with explicit subject lists"],"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-08T10:18:20.063Z"}