A jar packed with sweets such as jelly and jam can be very deceiving. Inspect the top surface carefully before deciding to buy. Do not buy if the surface is not visible, cap is covering the headspace, the label is covering the headspace or the tamper proof seal is translucent. There is no way to assure whether it is good or not other than opening. In case you are desperate, do open it immediately after paying. Then return if bad.
Reasons for moldy incident:
Molds need to meet three conditions for growth; moisture, carbohydrate and oxygen. Notice it growing on old moist rice but not on old dry rice.
The mold on top of jelly met all the three conditions. The jelly is rich in sugar, it is about 60% sugar. It is indeed moist and perhaps have enough available water. Improper sealing allowed the oxygen entry.
Do I need to mention that this jelly was improperly processed?