response.To says it copies request state into the response, but it currently reuses the same Desired and Context pointers.
That means a function can mutate the original request just by updating the response after To(...). This is easy to hit in normal SDK usage because functions commonly call response.To(...) and then add desired resources or context entries.
Repro:
- Build a request with
Desired and Context.
- Call
rsp := response.To(req, ttl).
- Mutate
rsp.Desired or rsp.Context.
req changes too.
Expected: To should deep copy request state before returning the response.
response.Tosays it copies request state into the response, but it currently reuses the sameDesiredandContextpointers.That means a function can mutate the original request just by updating the response after
To(...). This is easy to hit in normal SDK usage because functions commonly callresponse.To(...)and then add desired resources or context entries.Repro:
DesiredandContext.rsp := response.To(req, ttl).rsp.Desiredorrsp.Context.reqchanges too.Expected:
Toshould deep copy request state before returning the response.