Mandatory attack effects (such as from Lure or abilities that say a creature "must attack each combat if able") only require the creature to attack if it is both able to attack AND a legal target exists for it. CR 508.1 explains that during the declare attackers step, the active player declares attackers, and CR 508.1d clarifies that a creature that is required to attack must do so if able — but "able" inherently requires a legal target to be available.
Creatures cannot be declared as attackers unless they are attacking either a player, a planeswalker that player controls, or a battle — these are the legal attack targets defined in CR 508.1a. If none of those exist (for example, all opponents and their permanents are somehow absent from the game, or a rule restricts valid targets), there is simply no legal way to attack, and the mandatory attack requirement is satisfied vacuously.
Importantly, failing to attack when required is a "cheating" situation only if a legal attack was actually possible and the player declined. CR 508.1d specifies the creature must attack "if able" — if unable, there is no infraction and no game loss.
Concrete example: Your only creature has "This creature attacks each combat if able" but your only opponent has an effect that says creatures cannot attack them this turn, and they control no planeswalkers or battles. Your creature simply does not attack — no rule is broken, because it was not "able" to attack.
This also applies to effects like Lure, which force creatures to block if able: if no creatures are available to block, the requirement is satisfied without any penalty (CR 509.1c).
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.