Repository navigation
Commit f3da388
authored
[cli/import] Strip InputType after union reduction in structural typing (#23115)
## Summary
`valueStructurallyTypedAs` (`pkg/importer/hcl2.go`) strips
`*schema.InputType` from its `schemaType` argument **before** calling
`reduceUnionType`, but `reduceUnionType` returns whichever union element
fits as-is. Schema-bound unions almost always have
`*schema.InputType`-wrapped members (e.g. `Input<Obj0>`), so the
post-union type switch never matches and the function returns `false`
even when the value structurally matches the underlying type.
The visible symptom is that `GenerateHCL2Definition` logs `"dropped
non-conforming value from object type"` and silently drops the entry: an
input like `{"k": {}}` against `Map<Union<Input<Obj0>, Input<Archive>>>`
round-trips to `{}` when `Obj0` has no required properties.
This is the root cause of the `TestRapidGenerateHCL2Definition` failure
on
https://github.com/pulumi/pulumi/actions/runs/25798683952/job/75783074303?pr=23112
(the rapid shrinker minimised it to a value with `b = {"":{}}` whose
element type was `Input<Union<Input<a-:index:Obj0•Input>,
Input<pulumi:pulumi:Archive>>>`).
Fix: reapply the `*schema.InputType`-strip loop after the union
reduction so the switch sees the unwrapped element type.
## Test plan
- [x] `go test -count=1 -tags all -timeout 5m ./importer -run
TestRapidGenerateHCL2Definition -rapid.seed=10040562407060112324` — the
exact seed from the linked CI run, now passes.
- [x] `go test -count=1 -tags all ./importer` — the existing
`valueStructurallyTypedAs` unit tests still pass; the fix is strictly
additive (it never flips `true` to `false`).
- [ ] Note: this test still flakes from at least one other unrelated
importer bug (`valueStructurallyTypedAs` doesn't handle
`*schema.EnumType` in its primitive-value cases). That is out of scope
here and will be addressed separately.
Fixes #231051 parent 11a5257 commit f3da388
3 files changed
Lines changed: 113 additions & 1 deletion
File tree
- changelog/pending
- pkg/importer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
611 | 617 | | |
612 | 618 | | |
613 | 619 | | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
614 | 630 | | |
615 | | - | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
616 | 635 | | |
617 | 636 | | |
618 | 637 | | |
619 | 638 | | |
620 | 639 | | |
621 | 640 | | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
622 | 648 | | |
623 | 649 | | |
624 | 650 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1112 | 1112 | | |
1113 | 1113 | | |
1114 | 1114 | | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
1115 | 1197 | | |
1116 | 1198 | | |
1117 | 1199 | | |
| |||
0 commit comments