Commit 2c1b24b
fix(crafter): surface DNS-1123 validation errors instead of masking them
The material auto-discovery loop in AddMaterialContactFreeWithAutoDetectedKind
silently swallowed DNS-1123 validation errors because:
1. Variable shadowing: `m, err :=` inside the for loop created a new `err`
that never propagated to the outer scope, so the final error message was
always nil when all kinds failed.
2. No early validation: invalid material names (uppercase, underscores, dots)
were passed through the entire kind-probing loop before failing deep in
proto validation, with the real cause buried.
3. Proto-validation errors not detected: the loop treated schema-level
validation failures the same as kind mismatches, continuing to probe
instead of stopping.
Fixes:
- Replace `:=` with `=` to avoid shadowing the outer `err`
- Add DNS-1123 regex check at the top of AddMaterialContractFree
- Detect protovalidate.ValidationError in the auto-discovery loop and
break immediately instead of masking the real error
Fixes #2394
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>1 parent 7542585 commit 2c1b24b
2 files changed
+64
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
90 | 94 | | |
91 | 95 | | |
92 | 96 | | |
| |||
578 | 582 | | |
579 | 583 | | |
580 | 584 | | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
581 | 592 | | |
582 | 593 | | |
583 | 594 | | |
| |||
628 | 639 | | |
629 | 640 | | |
630 | 641 | | |
631 | | - | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
632 | 646 | | |
633 | | - | |
| 647 | + | |
634 | 648 | | |
635 | 649 | | |
636 | 650 | | |
| |||
639 | 653 | | |
640 | 654 | | |
641 | 655 | | |
642 | | - | |
643 | 656 | | |
644 | 657 | | |
645 | 658 | | |
| |||
649 | 662 | | |
650 | 663 | | |
651 | 664 | | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
652 | 673 | | |
653 | 674 | | |
654 | 675 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
539 | 539 | | |
540 | 540 | | |
541 | 541 | | |
| 542 | + | |
542 | 543 | | |
543 | 544 | | |
544 | 545 | | |
| |||
593 | 594 | | |
594 | 595 | | |
595 | 596 | | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
596 | 627 | | |
597 | 628 | | |
598 | 629 | | |
| |||
613 | 644 | | |
614 | 645 | | |
615 | 646 | | |
616 | | - | |
| 647 | + | |
617 | 648 | | |
618 | 649 | | |
619 | 650 | | |
| |||
622 | 653 | | |
623 | 654 | | |
624 | 655 | | |
625 | | - | |
626 | | - | |
627 | | - | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
628 | 663 | | |
| 664 | + | |
629 | 665 | | |
630 | 666 | | |
631 | 667 | | |
| |||
0 commit comments