Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

go composition function: observed XR managedFields leak into SSA status patch

Open
#182 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
go, kubernetes
Domain
api, backend

Research direction

Start with internal/xfn/utils.go, especially AsStruct(), and composition_functions.go where the SSA status patch is built. Reproduce the difference between crossplane render and a cluster response containing metadata.managedFields, then trace where that field reaches the desired composite resource. Done means the generated-struct round trip no longer produces a rejected SSA status patch, with coverage for managedFields.

Written by the indexing model from the issue text.

Description

bug
What happened?

I am using the Crossplane project sturcture generating the go structs for the composed and composite
resources. The object retains the ManagedFields from the request and when set to the response via

    mapAny, err := runtime.DefaultUnstructuredConverter.ToUnstructured(goStructOfComposite)
    unstr := unstructured.Unstructured{Object: mapAny}
    response.SetDesiredCompositeResource(rsp, &resource.Composite{Resource: &composite.Unstructured{Unstructured: unstr}}),

the metadata.managedFields populated by the API server survive into the SSA patch
body, and Kubernetes rejects it

Below is an analysis by Claude:

When a Go composition function round-trips the observed XR through a generated
struct and calls response.SetDesiredCompositeResource, the
metadata.managedFields populated by the API server survive into the SSA patch
body, and Kubernetes rejects it:

cannot apply composite resource status: metadata.managedFields must be nil

AsStruct() (L52–76)
copies the full observed XR backing map into the RunFunctionRequest proto
without stripping managedFields. Generated ObjectMeta structs include
ManagedFields *[]ManagedFieldsEntry, so the field survives the Go struct
round-trip and reaches the
SSA patch in composition_functions.go,
where Kubernetes rejects it.

crossplane render does not populate managedFields
in the observed XR proto, so render passes while the cluster fails.

Workaround: call unstr.SetManagedFields(nil) before SetDesiredCompositeResource.

Related: crossplane/crossplane#7453

What environment did it happen in?
Crossplane version: v2.3.2, v2.3.

Dominant language
Go
Stars
19
Forks
31
Avg merge
2d 15h
Merged PRs (30d)
53

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from crossplane/cli

All issues in crossplane/cli

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.