Add assertions to prevent reintroducing this bug in the future.