Add assertion for nil on invalid key