I guess the real question is: how can we check if a principal refers to a canister or a user (to avoid these kind of situations)?
This thread seems to suggest that we can’t.
But this code by @witter seems to suggest that we can.