Commit 8de3a29
committed
refactor(cfn-lang-ext): consolidate copy helpers and relocate prop-name helpers
PR #9009 (issue #9005) left two near-duplicate copy helpers in the language-
extensions code: _copy_artifact_uris_for_type in samcli/lib/package/
language_extensions_packaging.py and _copy_artifact_paths in samcli/commands/
build/build_context.py. They were 90% identical and differed only in the
optional dynamic_prop_keys skip-set. Bot review #1 on that PR caught the
exact bug class this duplication enables — a flat-key .get() slipping into
one helper while the other had been jmespath-aware.
Promote the four prop-name helpers (_get_prop_value, _set_prop_value,
_leaf_prop_name, _resolve_property_paths) — until now underscore-private
helpers in language_extensions_packaging.py imported across packages by
samcli/commands/build and samcli/lib/cfn_language_extensions/sam_integration —
into a properly-named module samcli/lib/cfn_language_extensions/property_paths
with no leading underscore. Add a fifth helper, copy_artifact_properties,
that consolidates the two duplicated copy implementations into one.
Add a contract test that asserts every entry in PACKAGEABLE_RESOURCE_
ARTIFACT_PROPERTIES round-trips through set_prop_value / get_prop_value and
that every leaf is alphanumeric (a precondition for use in CloudFormation
Mapping names and Fn::FindInMap third-arg keys). Future additions to the
canonical packageable-resource list are now caught at the contract layer
rather than at user-template execution time.
Mechanical changes:
- new samcli/lib/cfn_language_extensions/property_paths.py
- new tests/unit/lib/cfn_language_extensions/test_property_paths.py
- delete _copy_artifact_uris_for_type from
samcli/lib/package/language_extensions_packaging.py; collapse its two
in-file callers (_copy_artifact_uris and _update_foreach_with_s3_uris)
to call copy_artifact_properties directly
- delete BuildContext._copy_artifact_paths from samcli/commands/build/
build_context.py; inline the single call site
- update inline imports in build_context.py and sam_integration.py to
point at the new module
- rename test_copy_artifact_uris_for_type_* to test_copy_artifact_properties_*
in tests/unit/commands/package/test_package_context.py and update
function-import sites in three test files
- delete duplicate get_prop_value / set_prop_value tests from
test_package_context.py (now in test_property_paths.py)
Verification:
- baseline 9191 passed, 25 skipped → after 9203 passed, 25 skipped (+12)
- ruff check, mypy, black --check all clean
- end-to-end #9005 repro (sam package against
language-extensions/tc-026-nested-application) still rewrites
Properties.Location to an https://s3... URL1 parent 9ffa5ed commit 8de3a29
8 files changed
Lines changed: 429 additions & 284 deletions
File tree
- samcli
- commands/build
- lib
- cfn_language_extensions
- package
- tests/unit
- commands
- buildcmd
- package
- lib/cfn_language_extensions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
507 | | - | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
508 | 514 | | |
509 | 515 | | |
510 | 516 | | |
| |||
552 | 558 | | |
553 | 559 | | |
554 | 560 | | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
561 | 566 | | |
| 567 | + | |
562 | 568 | | |
563 | 569 | | |
564 | 570 | | |
| |||
606 | 612 | | |
607 | 613 | | |
608 | 614 | | |
609 | | - | |
610 | | - | |
| 615 | + | |
| 616 | + | |
611 | 617 | | |
612 | 618 | | |
613 | 619 | | |
614 | 620 | | |
615 | 621 | | |
616 | 622 | | |
617 | | - | |
| 623 | + | |
618 | 624 | | |
619 | 625 | | |
620 | 626 | | |
| |||
653 | 659 | | |
654 | 660 | | |
655 | 661 | | |
656 | | - | |
| 662 | + | |
657 | 663 | | |
658 | 664 | | |
659 | 665 | | |
| |||
664 | 670 | | |
665 | 671 | | |
666 | 672 | | |
667 | | - | |
| 673 | + | |
668 | 674 | | |
669 | 675 | | |
670 | 676 | | |
| |||
723 | 729 | | |
724 | 730 | | |
725 | 731 | | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
730 | 736 | | |
731 | 737 | | |
732 | 738 | | |
| |||
740 | 746 | | |
741 | 747 | | |
742 | 748 | | |
743 | | - | |
744 | | - | |
| 749 | + | |
| 750 | + | |
745 | 751 | | |
746 | 752 | | |
747 | 753 | | |
748 | | - | |
| 754 | + | |
749 | 755 | | |
750 | 756 | | |
751 | 757 | | |
| |||
788 | 794 | | |
789 | 795 | | |
790 | 796 | | |
791 | | - | |
| 797 | + | |
792 | 798 | | |
793 | 799 | | |
794 | | - | |
| 800 | + | |
795 | 801 | | |
796 | 802 | | |
797 | 803 | | |
| |||
830 | 836 | | |
831 | 837 | | |
832 | 838 | | |
833 | | - | |
| 839 | + | |
834 | 840 | | |
835 | | - | |
| 841 | + | |
836 | 842 | | |
837 | 843 | | |
838 | 844 | | |
| |||
936 | 942 | | |
937 | 943 | | |
938 | 944 | | |
939 | | - | |
| 945 | + | |
940 | 946 | | |
941 | 947 | | |
942 | 948 | | |
943 | 949 | | |
944 | 950 | | |
945 | 951 | | |
946 | 952 | | |
947 | | - | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
959 | | - | |
960 | | - | |
961 | | - | |
962 | | - | |
963 | | - | |
964 | | - | |
965 | | - | |
966 | | - | |
967 | | - | |
968 | | - | |
969 | | - | |
970 | | - | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
975 | | - | |
976 | | - | |
977 | | - | |
| 953 | + | |
978 | 954 | | |
979 | 955 | | |
980 | 956 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
415 | | - | |
| 415 | + | |
416 | 416 | | |
417 | | - | |
418 | | - | |
| 417 | + | |
| 418 | + | |
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
| |||
0 commit comments