The bag inflated, or the container pressurized
Updated
On this page7
It is not spoilage
Nothing has gone wrong with the coffee. Carbon dioxide produced during roasting is leaving the bean and has accumulated in a sealed space. The product inside is usually fine and the package is telling you about your timing.
Which means the fix is upstream
Either rest the coffee longer before packing, or pack into something that can vent. Those are the only two options and they trade against each other: resting costs freshness and space, venting costs the simplicity of a plain airtight container.
Ground coffee does it faster and harder
Grinding releases the gas much more quickly, so a ground product packed immediately after grinding will pressurize within hours rather than days. If the problem appeared overnight rather than over a week, this is why.
In a rigid container it is a handling issue
A pail or canister that has built pressure can open abruptly and throw product. It is not dangerous in the way a fermenting bottle is and it is enough to make a mess and startle somebody, which at a counter is worse than it sounds.
Darker roasts degas more
More of the reaction has happened, so there is more gas to release. A resting period that is adequate for a light roast may not be for a dark one, which is a reason to set resting times per profile rather than as one house rule.
Record the rest time
Roast date, pack date and the gap between them, per batch. Without those three you cannot tell an inadequate rest from a packaging failure, and they are the same two numbers that answer most freshness questions.