Hello F.,
Suppress just the keyword state, before the definition of the attribute of the state3 (as state5), like:
@startuml
state "State1 has a long name" as state1
state1: Has an attribute and\ncorrectly shows long name
state "Long Composite State" as composite {
state "State2 has a long name" as state2
state "State3 has a long name" as state3
state3: Adding an Attribute\nbreaks the long name\nand shows its alias instead
state2 --> state3
||
state state4
state state5
state5: An attribute
state4 --> state5
}
@enduml
Then we observe the expected result:

If that can help,
Regards,
Th.