crossplane / crossplane/function-sdk-go

response.To aliases request desired state and context

Open
#314 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
36
Forks
29
Avg merge
1d 8h
Merged PRs (30d)
10

Description

`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:
1. Build a request with `Desired` and `Context`.
2. Call `rsp := response.To(req, ttl)`.
3. Mutate `rsp.Desired` or `rsp.Context`.
4. `req` changes too.

Expected: `To` should deep copy request state before returning the response.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.