{"record":{"id":"b05f12bb4d941648","repo":"nats-io/nats-server","slug":"pool-size-cannot-be-negative-if-pinned-accounts-ar","errorCode":null,"errorMessage":"pool_size cannot be negative if pinned accounts are specified","messagePattern":"pool_size cannot be negative if pinned accounts are specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/server.go","lineNumber":1142,"sourceCode":"\t// Check that cluster name if defined matches any gateway name.\n\t// Note that we have already verified that the gateway name does not have spaces.\n\tif o.Gateway.Name != _EMPTY_ && o.Gateway.Name != o.Cluster.Name {\n\t\tif o.Cluster.Name != _EMPTY_ {\n\t\t\treturn ErrClusterNameConfigConflict\n\t\t}\n\t\t// Set this here so we do not consider it dynamic.\n\t\to.Cluster.Name = o.Gateway.Name\n\t}\n\tclusterName := o.Cluster.Name\n\tif clusterName == _EMPTY_ && len(o.LeafNode.Remotes) > 0 && o.Cluster.Port == 0 {\n\t\tclusterName = o.ServerName\n\t}\n\tif clusterName == leafNoOriginCluster {\n\t\treturn ErrClusterNameReserved\n\t}\n\tif l := len(o.Cluster.PinnedAccounts); l > 0 {\n\t\tif o.Cluster.PoolSize < 0 {\n\t\t\treturn fmt.Errorf(\"pool_size cannot be negative if pinned accounts are specified\")\n\t\t}\n\t\tm := make(map[string]struct{}, l)\n\t\tfor _, a := range o.Cluster.PinnedAccounts {\n\t\t\tif _, exists := m[a]; exists {\n\t\t\t\treturn fmt.Errorf(\"found duplicate account name %q in pinned accounts list %q\", a, o.Cluster.PinnedAccounts)\n\t\t\t}\n\t\t\tm[a] = struct{}{}\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc validatePinnedCerts(pinned PinnedCertSet) error {\n\tre := regexp.MustCompile(\"^[a-f0-9]{64}$\")\n\tfor certId := range pinned {\n\t\tentry := strings.ToLower(certId)\n\t\tif !re.MatchString(entry) {\n\t\t\treturn fmt.Errorf(\"error parsing 'pinned_certs' key %s does not look like lower case hex-encoded sha256 of DER encoded SubjectPublicKeyInfo\", entry)","sourceCodeStart":1124,"sourceCodeEnd":1160,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/server.go#L1124-L1160","documentation":"validateCluster rejects the configuration when cluster.pinned_accounts is non-empty and cluster.pool_size is negative: pinned accounts require a known pool size so the server can pre-allocate internal structures per account, so a negative (unset/computed) pool size is invalid in that combination.","triggerScenarios":"Thrown at server/server.go:1142 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set cluster.pool_size to a non-negative value (e.g. the number of expected accounts)","Remove cluster.pinned_accounts if pooling is not needed","Use an explicit pool_size instead of relying on auto-sizing"],"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"}