Skip to content

Commit da1ee07

Browse files
dylanratcliffeactions-user
authored andcommitted
Attach mapping errors to MappedItemDiff (#2234)
This means that if the mapping fails in the CLI before a query is generated, we will still get an error. Currently we only get an error if there is a query but it fails. This will mean much higher fidelity errors ion the timeline's mapping step GitOrigin-RevId: 5d99c1a63a03c0116a187f4e0e8ad6041183b48a
1 parent fc02f92 commit da1ee07

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎tfutils/plan_mapper.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,19 @@ func mapResourceToQuery(itemDiff *sdp.ItemDiff, terraformResource *Resource, map
325325
}
326326

327327
// If we get to this point, we haven't found a mapping
328+
message := fmt.Sprintf("missing mapping attribute: %v", strings.Join(attemptedMappings, ", "))
328329
return PlannedChangeMapResult{
329330
TerraformName: terraformResource.Address,
330331
TerraformType: terraformResource.Type,
331332
Status: MapStatusNotEnoughInfo,
332-
Message: fmt.Sprintf("missing mapping attribute: %v", strings.Join(attemptedMappings, ", ")),
333+
Message: message,
333334
MappedItemDiff: &sdp.MappedItemDiff{
334335
Item: itemDiff,
335336
MappingQuery: nil, // unmapped item has no mapping query
337+
MappingError: &sdp.QueryError{
338+
ErrorType: sdp.QueryError_OTHER,
339+
ErrorString: message,
340+
},
336341
},
337342
}
338343
}

0 commit comments

Comments
 (0)