As mentioned in other answers regarding the 2022 Ukraine conflict, there is a defense clause for the existing EU countries. I looked and found §42.7 TEU,
If a Member State is the victim of armed aggression on its territory, the other Member States shall have towards it an obligation of aid and assistance by all the means in their power, [...]
The key word for me is "shall", which is less than "must". Also, it seems pretty easy to me for a country to argue that right now, for whatever reasons, the "means in their power" are, alas, pretty much limited to sending a few crates of token equipment.
The article continues with further constraints:
This shall not prejudice the specific character of the security and defence policy of certain Member States.
Commitments and cooperation in this area shall be consistent with commitments under the North Atlantic Treaty Organisation, which, [...]
So all in all, this seems like having no real bite whatsoever, and is just a vague declaration of intent, which would, in practice be of no importance whatsoever compared to actual real world politics or military strategies of the individual countries.
Is my interpretation correct? Has this been discussed a lot in the past (or currently) within the EU? Have books been written about this; is there a consensus about it in diplomatic circles? Obviously we have not tested this article so far, but what would be the most probable outcome these days?