Skip to content

response.To aliases request desired state and context #314

@immanuwell

Description

@immanuwell

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions