{"record":{"id":"99badd0ea6f81dd1","repo":"cilium/cilium","slug":"nat-stats-config-q-must-be-between-d-d","errorCode":null,"errorMessage":"nat-stats config: %q must be between [%d, %d]","messagePattern":"nat-stats config: %q must be between \\[(.+?), (.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/maps/nat/stats/stats.go","lineNumber":136,"sourceCode":"\tNatMap4   nat.NatMap4\n\tNatMap6   nat.NatMap6\n\tJobs      job.Group\n\tMetrics   natMetrics\n\tConfig    Config\n\tLBConfig  loadbalancer.Config\n\tHealth    cell.Health\n}\n\nconst nodePortMaxNAT = 65535\n\nfunc newStats(params params) (*Stats, error) {\n\tif params.Config.NATMapStatInterval == 0 {\n\t\treturn nil, nil\n\t}\n\n\tif params.Config.NatMapStatKStoredEntries > maxNatMapStatKStoredEntries ||\n\t\tparams.Config.NatMapStatKStoredEntries < minNatMapStatKStoredEntries {\n\t\treturn nil, fmt.Errorf(\"nat-stats config: %q must be between [%d, %d]\",\n\t\t\tnatMapStatsEntriesName, minNatMapStatKStoredEntries, maxNatMapStatKStoredEntries)\n\t}\n\n\t// number of available source-ports is ephemeral range subtracting those\n\t// used by node-ports.\n\tmaxAvailPorts := nodePortMaxNAT - (params.LBConfig.NodePortMax + 1)\n\tm := &Stats{\n\t\tlogger:   params.Logger,\n\t\tmetrics:  params.Metrics,\n\t\tconfig:   params.Config,\n\t\tmaxPorts: int(maxAvailPorts),\n\t\tdb:       params.DB,\n\t\ttable:    params.Table,\n\t}\n\n\tm.observable4, m.next4, m.complete4 =\n\t\tstream.Multicast[TupleCountIterator]()\n\tm.observable6, m.next6, m.complete6 =","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/maps/nat/stats/stats.go#L118-L154","documentation":"The NAT statistics cell validates nat-map-stats-entries in newStats: if NatMapStatKStoredEntries is not in [1, 4096] (min..maxNatMapStatKStoredEntries), startup of the stats cell fails with this error. Interval of 0 disables the feature and skips validation.","triggerScenarios":"Setting nat-map-stats-entries to 0 or a negative number, or to anything above 4096, while nat-map-stats-interval is non-zero (feature enabled).","commonSituations":"Operators raising the stored-entries value for busy clusters and overshooting the 4096 cap; copy-pasted config with 0 entries while an interval is configured; misreading the option as a byte/KB size.","solutions":["Set nat-map-stats-entries to a value between 1 and 4096 inclusive","If you need more than 4096, keep 4096 (the supported maximum) or disable the feature with nat-map-stats-interval=0","Verify both options together: entries validation only runs when the interval is non-zero"],"exampleFix":"// before\nnat-map-stats-interval=30s\nnat-map-stats-entries=8192\n// error: \"nat-map-stats-entries\" must be between [1, 4096]\n// after\nnat-map-stats-interval=30s\nnat-map-stats-entries=4096","handlingStrategy":"validation","validationCode":"const minNatMapStatKStoredEntries, maxNatMapStatKStoredEntries = 1, 4096\nif natStatsInterval != 0 && (natMapStatEntries > maxNatMapStatKStoredEntries || natMapStatEntries < minNatMapStatKStoredEntries) {\n    return fmt.Errorf(\"nat-map-stats-entries must be in [%d, %d]\", minNatMapStatKStoredEntries, maxNatMapStatKStoredEntries)\n}","typeGuard":"null","tryCatchPattern":"if err := startNatStatsCell(params); err != nil && strings.Contains(err.Error(), \"nat-stats config\") {\n    log.Error(\"invalid nat-map-stats-entries; must be 1..4096 (or disable via interval=0)\", \"err\", err)\n}","preventionTips":["Keep nat-map-stats-entries within 1..4096","Remember validation only runs when nat-map-stats-interval is non-zero; set interval=0 to disable the feature","Clamp the configured value before passing it to the agent","Read the option as an entry count, not a size"],"tags":["config","nat","stats","validation"],"backgroundTag":"config-value-out-of-range","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}