This has happened a couple of times, where a civ's relations with me are cordial or better (in my current game, warm) and then they declare war on me without warning. It used to be that I could feel pretty sure about something like this, now the game feels really random.