{"record":{"id":"e704a948be5774f2","repo":"TechnitiumSoftware/DnsServer","slug":"percentage-value-valid-range-is-between-0-and-100","errorCode":null,"errorMessage":"Percentage value valid range is between 0 and 100.","messagePattern":"Percentage value valid range is between 0 and 100\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/DnsServer.cs","lineNumber":7480,"sourceCode":"        public int QpmLimitSampleMinutes\n        {\n            get { return _qpmLimitSampleMinutes; }\n            set\n            {\n                if ((value < 1) || (value > 60))\n                    throw new ArgumentOutOfRangeException(nameof(QpmLimitSampleMinutes), \"Valid range is between 1 and 60 minutes.\");\n\n                _qpmLimitSampleMinutes = value;\n            }\n        }\n\n        public int QpmLimitUdpTruncationPercentage\n        {\n            get { return _qpmLimitUdpTruncationPercentage; }\n            set\n            {\n                if ((value < 0) || (value > 100))\n                    throw new ArgumentOutOfRangeException(nameof(QpmLimitUdpTruncationPercentage), \"Percentage value valid range is between 0 and 100.\");\n\n                _qpmLimitUdpTruncationPercentage = value;\n            }\n        }\n\n        public IReadOnlyCollection<NetworkAddress> QpmLimitBypassList\n        {\n            get { return _qpmLimitBypassList; }\n            set\n            {\n                if ((value is null) || (value.Count == 0))\n                    _qpmLimitBypassList = null;\n                else if (value.Count > byte.MaxValue)\n                    throw new ArgumentOutOfRangeException(nameof(QpmLimitBypassList), \"Networks cannot have more than 255 entries.\");\n                else\n                    _qpmLimitBypassList = value;\n            }\n        }","sourceCodeStart":7462,"sourceCodeEnd":7498,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/DnsServer.cs#L7462-L7498","documentation":"Thrown by the QpmLimitUdpTruncationPercentage property setter when the value is below 0 or above 100. This percentage controls how often UDP responses are truncated (TC bit) when QPM limits are exceeded, before the limit hard-blocks queries.","triggerScenarios":"Setting server.QpmLimitUdpTruncationPercentage to an int < 0 or > 100.","commonSituations":"Passing a fraction (e.g. 0.5) as an integer resulting in 0 unexpectedly; config file with a value like 150; misunderstanding that 0 means never truncate and 100 means always truncate.","solutions":["Set a value between 0 and 100 inclusive (e.g. 50 for 50% truncation).","If your config uses a 0-1 float, multiply by 100 and round before assignment."],"exampleFix":"// before\nserver.QpmLimitUdpTruncationPercentage = 150; // throws\n\n// after\nserver.QpmLimitUdpTruncationPercentage = 50;","handlingStrategy":"validation","validationCode":"int safePct = Math.Clamp(value, 0, 100);\nserver.QpmLimitUdpTruncationPercentage = safePct;","typeGuard":"static bool IsValidPercentage(int p) => p >= 0 && p <= 100;","tryCatchPattern":"try { server.QpmLimitUdpTruncationPercentage = value; }\ncatch (ArgumentOutOfRangeException) { server.QpmLimitUdpTruncationPercentage = 50; }","preventionTips":["If config uses 0.0-1.0 floats, multiply by 100 and round first.","Use Math.Clamp on loaded values."],"tags":["dns","qpm","rate-limiting","udp","configuration"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}