The bug
The hitbox of villagers and baby villagers is too small when they are in a bed.
How to reproduce
Spawn a baby villager or a villager
Place a bed near the villager
Set the time to night
Press
F3+B
to show hitboxesLook at the villager's hitbox once it is in bed
Examples
[media][media]
Linked issues
is duplicated by
relates to
Attachments
Comments
still present in 20w18a
still present in 20w19a
still present in 20w20a
still present in 20w22a
Affects 20w45a
Can confirm in 21w11a.
Likely WF per MC-10919
Can confirm in 1.17.

Can confirm in 1.17.1 Release Candidate 1.

Can confirm in 1.18 Pre-release 4.
Can confirm in 1.18.
Can confirm in 1.18.1.
Can confirm in 1.18.2 and 22w13a.
Can confirm in 1.19.
Can confirm in 1.19.2.

I thought this is where the bug comes from (decompiled 1.20.2 using vanilla mapping:
net.minecraft.world.entity.LivingEntity.class
protected static final EntityDimensions SLEEPING_DIMENSIONS = EntityDimensions.fixed(0.2F, 0.2F);
...
public EntityDimensions getDimensions(Pose $$0) {
return ($$0 == Pose.SLEEPING) ? SLEEPING_DIMENSIONS : super.getDimensions($$0).scale(getScale());
}
and it affects MC-10919 as well.
No way that got added by accident.

Can confirm in 1.21.4.
still present in 20w16a