UserDef::processUser has two fallbacks that are in my opinion dangerous and unwanted in some code.
If a user ID was given but no user was found, it will return
new UserIdentityValue( 0, "Unknown user" )
If given a valid user name but no user with that name exists, it returns
new UserIdentityValue( 0, $canonicalName )
The first case is awkward to handle for the caller, the second one is a bit better but still surprising. I believe there should be a way to make it return null or throw an exception in those cases. Possibly, the current behaviour would be removed altogether if nobody is relying on it.
These were introduced in https://gerrit.wikimedia.org/r/c/mediawiki/core/+/703416 and haven't changed since then.