The war in Ukraine is the consequence of the dissolution of a state, rather than a war between states, much like what happened in Yugoslavia, Lebanon, and during the Balkan Wars at the beginning of the 20th century. Before 1992, Russia was divided into 14 republics—theoretically sovereign states—but they were, in reality, administrative divisions. We find the same structure in the USA or Brazil, which are federations of states.
The only reasonable solution would be to ask the communities themselves which state they wish to join, but a certain amount of compromise is always necessary. For instance, we fought a war to liberate Trento and Trieste, but no one ever thought of liberating Canton Ticino (in Switzerland).