-
-
Couldn't load subscription status.
- Fork 77
Description
A Value containing a set cannot use the path argument within a Transform callback for all paths.
Given an object like so:
ObjectVal(map[string]Value{
"set": SetVal([]Value{
ObjectVal(map[string]Value{
"attr": StringVal("val"),
}),
}),
})
Using Transform to obtain each step's value from another object will encounter a path which cannot be used.
// using the same value to ensure all paths are valid, and should result in the same value
Transform(val, func(p Path, v Value) (Value, error) {
return p.Apply(val)
})
This results in at step 1: key value not number or string when the path is for
cty.Path{cty.GetAttrStep{Name:"set"}, cty.IndexStep{Key:cty.ObjectVal(map[string]cty.Value{"attr":cty.StringVal("val")})}, cty.GetAttrStep{Name:"attr"}}
I'm not sure how we would intend to handle this. Sets are not currently index-able, so simply skipping the key value not number or string check doesn't work. Should we make all Path values valid for Apply on a correctly shaped Value, have special handling to detect when a set is encountered in the path, or maybe just document this as a potential hazard within Transform and Walk?