{"record":{"id":"8c28c04d0625c400","repo":"TechnitiumSoftware/DnsServer","slug":"no-reserved-lease-was-found-for-client-identifier","errorCode":null,"errorMessage":"No reserved lease was found for client identifier: {clientIdentifier}","messagePattern":"No reserved lease was found for client identifier: (.+?)","errorType":"exception","errorClass":"DhcpServerException","httpStatus":null,"severity":"warning","filePath":"DnsServerCore/Dhcp/Scope.cs","lineNumber":1596,"sourceCode":"\n            foreach (KeyValuePair<ClientIdentifierOption, Lease> entry in _leases)\n            {\n                Lease lease = entry.Value;\n\n                if ((lease.Type == LeaseType.Reserved) && lease.HardwareAddress.SequenceEqual(hardwareAddressBytes))\n                {\n                    ConvertToDynamicLease(lease);\n                    return;\n                }\n            }\n\n            throw new DhcpServerException(\"No reserved lease was found for hardware address: \" + hardwareAddress);\n        }\n\n        public void ConvertToDynamicLease(ClientIdentifierOption clientIdentifier)\n        {\n            if (!_leases.TryGetValue(clientIdentifier, out Lease lease) || (lease.Type != LeaseType.Reserved))\n                throw new DhcpServerException(\"No reserved lease was found for client identifier: \" + clientIdentifier.ToString());\n\n            ConvertToDynamicLease(lease);\n        }\n\n        public void WriteTo(Stream s)\n        {\n            BinaryWriter bW = new BinaryWriter(s);\n\n            bW.Write(Encoding.ASCII.GetBytes(\"SC\"));\n            bW.Write((byte)10); //version\n\n            s.WriteShortString(_name);\n            bW.Write(_enabled);\n            _startingAddress.WriteTo(bW);\n            _endingAddress.WriteTo(bW);\n            _subnetMask.WriteTo(bW);\n            bW.Write(_leaseTimeDays);\n            bW.Write(_leaseTimeHours);","sourceCodeStart":1578,"sourceCodeEnd":1614,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dhcp/Scope.cs#L1578-L1614","documentation":"Thrown by Scope.ConvertToDynamicLease(ClientIdentifierOption) when no lease exists for the identifier OR the existing lease is not Reserved. TryGetValue false or lease.Type != LeaseType.Reserved both raise this DhcpServerException.","triggerScenarios":"Calling scope.ConvertToDynamicLease(clientId) for an unknown client identifier, a client whose lease is already Dynamic, or an identifier with a mismatched hardware-address type.","commonSituations":"Demoting a non-reserved client, repeated demotion, or identifier byte/type mismatch with stored lease.","solutions":["Ensure a Reserved lease exists for the ClientIdentifierOption on this scope.","Skip the call if the lease is already Dynamic.","Reconcile state by removing and re-adding if needed.","Construct the ClientIdentifierOption with the stored hardware type."],"exampleFix":"// before\nscope.ConvertToDynamicLease(clientId);\n\n// after\nif (scope.Leases.TryGetValue(clientId, out var l) && l.Type == LeaseType.Reserved)\n    scope.ConvertToDynamicLease(clientId);","handlingStrategy":"try-catch","validationCode":"if (!scope.Leases.TryGetValue(clientIdentifier, out var lease) || lease.Type != LeaseType.Reserved) return;","typeGuard":"static bool HasReservedLeaseForClient(Scope scope, ClientIdentifierOption id)\n    => scope.Leases.TryGetValue(id, out var l) && l.Type == LeaseType.Reserved;","tryCatchPattern":"try { scope.ConvertToDynamicLease(clientIdentifier); }\ncatch (DhcpServerException ex) when (ex.Message.Contains(\"No reserved lease\"))\n{ /* lease absent or already dynamic */ }","preventionTips":["Verify lease type is Reserved before demoting.","Match the stored hardware-address type in the identifier.","Gate demote actions on current lease state."],"tags":["dhcp","lease","runtime-state","scope","reservation","client-id"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}