Unable to extract and merge by field manager

I understand what’s wrong. I have looked around everywhere to figure out what the fix could be. Really need help for it.
I have recreated the issue that you can easily run yourself: extract-merge-issue/pkg/myissue_test.go at main · subtleseeker/extract-merge-issue · GitHub

I have a component that tries to recreate the resource yaml by only keeping the fields that are owned by the field managers that I require. To do that, I “extract” those fields for every field manager and “merge” it in a new object.
One element of metadata.managedFields looks like:

{
                "apiVersion": "v1",
                "fieldsType": "FieldsV1",
                "fieldsV1": {
                    "f:spec": {
                        "f:ports": {
                            "k:{\"port\":80,\"protocol\":\"TCP\"}": {
                                "f:nodePort": {}
                            }
                        }
                    }
                },
                "manager": "kubectl-edit",
                "operation": "Update",
                "time": "2023-12-21T05:59:59Z"
            }

Here, after applying the yaml, I edit the field ports[0].nodePort with kubectl edit. The extract’ed value from the service yaml looks like:

{
    "spec": {
        "ports": [
            {
                "nodePort": 30001
            }
        ]
    }
}

If you see, this doesn’t contain the key {\"port\":80,\"protocol\":\"TCP\"} that is required field during a merge operation.
During merge, I see the error:

.spec.ports: element 0: associative list with keys has an element that omits key field "port" (and doesn't have default value)

I understand the extracted field doesn’t have the required fields. From extraction perspective, it shoudn’t have it either. I think the fix needs to be there in the ‘merge’ part. Can someone help in understanding this?

I have asked the same question in SO Kubernetes controller lib: Unable to extract and merge by field manager - Stack Overflow