-
Notifications
You must be signed in to change notification settings - Fork 13
Description
The Bug
SwampVersion.create() uses parseInt() to parse the calver components, which strips leading zeros. When toString() reconstructs the version string, the zero-padding is lost.
This means a build at 00:39:01 produces version 20260224.003901.0, but after round-tripping through SwampVersion:
SwampVersion.create("20260224.003901.0")
→ parseInt("003901") = 3901
→ toString() = "20260224.3901.0" // 💥 4 digits instead of 6
The version written to .swamp.yaml becomes 20260224.3901.0, which fails the UAT regex /^\d{8}\.\d{6}\.\d+$/ expecting exactly 6 digits in the time segment.
Why It Went Unnoticed
Every previous release was built during daytime hours where the HHMMSS component has no leading zeros:
234448(23:44:48) →parseInt→234448✓ (6 digits)170836(17:08:36) →parseInt→170836✓ (6 digits)150150(15:01:50) →parseInt→150150✓ (6 digits)
The first release built after midnight was 20260224.003901.0-sha.69631cc7 (00:39:01), and parseInt("003901") = 3901 — only 4 digits. This broke the UAT run.
Root Cause
src/domain/repo/swamp_version.ts lines 56-61:
const major = parseInt(match[1], 10); // date — always 8 digits, never has leading zeros
const minor = parseInt(match[2], 10); // time — CAN have leading zeros (00:00:00–09:59:59)
const patch = parseInt(match[3], 10); // patch — typically "0", no padding issueAnd toString() at line 106:
return `${this.major}.${this.minor}.${this.patch}`;
// No zero-padding — "20260224.3901.0" instead of "20260224.003901.0"Fix
toString() needs to zero-pad the components to preserve the calver format:
toString(): string {
const major = String(this.major).padStart(8, "0");
const minor = String(this.minor).padStart(6, "0");
return `${major}.${minor}.${this.patch}`;
}Or alternatively, store the raw string segments instead of parsing them as integers.