Commit 3362511
fix: fail fast on SPDX normalization errors (P0 fixes)
Critical improvements to SPDX UUID replacement:
1. **Type validation**: Check that documentNamespace is a string
- Prevents silent corruption when field has wrong type
- Returns clear error message with actual type
2. **Empty validation**: Check that documentNamespace is not empty
- Prevents invalid SBOM generation
- Fails fast instead of silently continuing
3. **UUID validation**: Fail if no UUID found in namespace
- Previously logged warning and continued (non-deterministic!)
- Now returns error with helpful message
- Alerts to potential Syft format changes
4. **Multiple UUID handling**: Log warning when multiple UUIDs found
- Documents intentional behavior (replace all with same UUID)
- Helps debugging unexpected formats
5. **Comprehensive edge case tests**:
- documentNamespace is not a string
- documentNamespace is empty
- documentNamespace has no UUID
- All cases now properly fail with clear errors
Benefits:
- Fails fast instead of silently producing non-deterministic builds
- Better error messages for debugging
- Catches unexpected SBOM format changes
- Prevents SBOM corruption
Addresses critical issues identified in PR review.
Co-authored-by: Ona <no-reply@ona.com>1 parent 48794b6 commit 3362511
2 files changed
+70
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
202 | 211 | | |
203 | | - | |
204 | | - | |
205 | 212 | | |
206 | 213 | | |
207 | 214 | | |
| |||
212 | 219 | | |
213 | 220 | | |
214 | 221 | | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
226 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
227 | 239 | | |
228 | 240 | | |
229 | 241 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
269 | 270 | | |
270 | 271 | | |
271 | 272 | | |
272 | 273 | | |
273 | 274 | | |
| 275 | + | |
274 | 276 | | |
275 | 277 | | |
276 | 278 | | |
277 | 279 | | |
278 | 280 | | |
| 281 | + | |
279 | 282 | | |
280 | 283 | | |
281 | 284 | | |
282 | 285 | | |
283 | 286 | | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
| 287 | + | |
289 | 288 | | |
290 | 289 | | |
291 | 290 | | |
| |||
353 | 352 | | |
354 | 353 | | |
355 | 354 | | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
370 | 362 | | |
371 | 363 | | |
372 | 364 | | |
| |||
463 | 455 | | |
464 | 456 | | |
465 | 457 | | |
466 | | - | |
| 458 | + | |
467 | 459 | | |
468 | 460 | | |
469 | 461 | | |
| |||
473 | 465 | | |
474 | 466 | | |
475 | 467 | | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
476 | 501 | | |
477 | 502 | | |
478 | 503 | | |
| |||
0 commit comments