Commit b039a47
fix: prevent cache pollution from builds without git metadata
CRITICAL FIX: The previous silent fallback to epoch 0 when commit is empty
caused cache pollution. Same source code would produce different checksums
depending on whether it was built from git clone or source tarball.
Changes:
1. **Fail fast in production**: Return error if no git commit and no SOURCE_DATE_EPOCH
2. **Support SOURCE_DATE_EPOCH**: Explicit override for reproducible builds
3. **Test environment detection**: Allow epoch fallback only in test binaries
4. **Clear error messages**: Guide users to fix their build environment
Why this matters:
- Prevents cache pollution (same source → different checksums)
- Maintains cache hit rates across build environments
- Forces proper git metadata in production builds
- Supports reproducible builds via SOURCE_DATE_EPOCH
Test environment detection:
- Checks if binary ends with '.test' (go test)
- Checks LEEWAY_TEST_MODE environment variable
- Only allows epoch fallback in tests
This ensures cache consistency and prevents silent failures that would
degrade cache performance over time.
Co-authored-by: Ona <[email protected]>1 parent a1bf26d commit b039a47
2 files changed
+66
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2401 | 2401 | | |
2402 | 2402 | | |
2403 | 2403 | | |
2404 | | - | |
| 2404 | + | |
| 2405 | + | |
2405 | 2406 | | |
2406 | 2407 | | |
2407 | 2408 | | |
2408 | | - | |
2409 | | - | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
2410 | 2428 | | |
2411 | 2429 | | |
2412 | 2430 | | |
| |||
2418 | 2436 | | |
2419 | 2437 | | |
2420 | 2438 | | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
2421 | 2455 | | |
2422 | 2456 | | |
2423 | 2457 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
0 commit comments