For weeks, the party leadership in Beijing had trumpeted the Brics summit as a chance to herald China’s vision for the group of emerging nations.
The meeting of the leaders of Brazil, Russia, India, China and South Africa in Fujian province was a big deal for Beijing.
So when North Korea conducted a nuclear test, its largest yet, as the summit was about to start on Sunday it was a slap in the face to the president, Xi Jinping.
This is a crucial time for the Chinese leadership and Kim Jong-un’s provocation highlights Beijing’s lack of diplomatic firepower.
Any action against Mr Kim depends on Mr Xi’s position at home. This, in turn depends on a pivotal 19th Communist Party congress next month.
Congresses occur every five years and this one marks the end of Mr Xi’s first five-year term in office and more intriguingly the start of his second term. He has to show he adheres to core party ideology, a true Red, while balancing the needs of an ever-expanding economy with a growing global presence.
To do this he has to pack the leadership with as many allies as he can to protect his back. There are power struggles. The party leader in Chongqing, Sun Zhengcai, a man tipped for the presidency and responsible for one of the world’s biggest cities, was axed from his position in July for disciplinary reasons - a catch-all phrase that indicates falling foul of the party hierarchy.
The investigation into Mr Sun, a former member of the Politburo, a key leadership body in the Communist Party, is reminiscent of the downfall during the 2012 congress of another Chongqing chief, Bo Xilai. He was sentenced to life in prison for corruption and abuse of power.
Next month’s party congress will see many of the 25 members of the Politburo replaced.
Most of the seven members of the supreme Politburo Standing Committee — excluding Mr Xi and the premier Li Keqiang — are also scheduled to retire. There had been murmurings that Mr Li’s position was less than ironclad but he seems to be back in favour.
Mr Xi and Mr Li have different priorities. Mr Xi places the party above economics. When he came to power five years ago, he demanded that the party elite read The Old Regime and the French Revolution written in 1856 by Alexis de Toucqueville.
But North Korea has its own agenda and relations between Beijing and Pyongyang are cooling.
The world changed in August when Beijing indicated to North Korea, a country so close to China that its relationship has been likened to teeth and gums, that if it initiates hostilities with the United States, it is on its own.
This was a huge foreign policy reset for China as it reduces its commitment to a country once considered its brother in arms.
In February, Beijing halted imports of North Korean coal for the rest of the year — ending a US$1 billion (Dh3.67bn) annual harvest for North Korea’s budget.
To North Korea’s dismay, China is now fully compliant with the unprecedented UN sanctions it signed up to in March 2016. Pyongyang responded by accusing Beijing of “dancing to the tune of the US”.
Nonetheless, China has limited but credible options.
One is to further tighten sanctions by targeting North Korean exports of textiles and clothing. Not headline grabbing but it would hurt Pyongyang. Many items of clothing with a “Made in China” label are actually made in North Korea.
Banning North Koreans from working in China, hitting the pockets of 80,000 or so North Koreans would also send a strong message.
And totally cutting off North Korea’s crude oil supply - 90 per cent already has been - would signal a complete rupture in relations. But this creates a nightmare scenario for Beijing. A massive refugee and security crisis just a few hundred kilometres from the Chinese capital, igniting massive social unrest.
China has one other option, the favoured one. Get North Korea and the US talking. While the US blames China for not reining in its “vassal state”, the Chinese reply that it is the US that needs to take the lead. Only negotiations can solve this crisis, they say.
All the while, in the back of the minds of the Beijing political elite is the timing of the congress. It starts on October 18. Considering what North Korea did to the Brics summit, Beijing is worried that something bigger may derail its congress and Mr Xi’s position.