Suppose a raging barbarian does not see any opponents on the battlefield but is attempting to maintain rage by attacking a hostile creature, according to the following:
Your rage lasts for 1 minute. It ends early if you are knocked unconscious or if your turn ends and you haven’t attacked a hostile creature since your last turn or taken damage since then.
If there was a successfully Hidden opponent on the field, the barbarian would be permitted to attack it by guessing its location. Even if they were incorrect, that would be sufficient to maintain their rage.
But how far ‘off’ is the barbarian allowed to be in their guess and still have the attack count?
Suppose the successfully Hidden opponent has actually left the field without the barbarian knowing. Does the fact that the opponent is not actually there prevent the barbarian from making an attack on an unseen opponent?
If yes, and the rage ends, the player then gains information about the fact that the opponent is not present (which seems to go against the spirit of "If the target isn’t in the location you targeted, you automatically miss, but the DM typically just says that the attack missed, not whether you guessed the target’s location correctly.")
If no, and the barbarian is allowed to attack an opponent that is not actually there based on the plausible belief that an opponent is present, then what prevents the barbarian from postulating an opponent who could be there? For example, the barbarian invokes an NPC that has successfully Hidden against the party before – is it enough to maintain rage for the barbarian to say that they believe said NPC is present and Hidden and then attempt to attack them as an Unseen opponent?
Somewhat related: A barbarian’s belief that they are attacking an opponent is not sufficient to maintain rage if what they are attacking is an illusion. So attacking a not-creature that is there is not enough to maintain rage, but is it enough to attack an actual creature that is not there?