Skip to content

Conversation

@mrIncompetent
Copy link
Contributor

@mrIncompetent mrIncompetent commented Jun 27, 2025

What

Fixes ExtractItems duplicating atomic elements when extracting from associative lists with WithAppendKeyFields.

Why

Items with elementRelationship: atomic were processed twice - once for direct path match and again during sub-path checking, causing duplication in the output.

Example

When extracting with fieldpaths:

  • .metadata.labels["app"]
  • .metadata.labels["version"]
  • .metadata.labels["env"]
  • .metadata.ownerReferences[uid="123e4567-e89b-12d3-a456-426614174000"]

Before fix - ownerReference was duplicated:

{
  "metadata": {
    "labels": {
      "app": "my-app",
      "version": "v1.0.0",
      "env": "prod"
    },
    "ownerReferences": [
      {
        "apiVersion": "apps/v1",
        "blockOwnerDeletion": true,
        "controller": true,
        "kind": "Deployment", 
        "name": "my-deployment",
        "uid": "123e4567-e89b-12d3-a456-426614174000"
      },
      {
        "apiVersion": "apps/v1",
        "blockOwnerDeletion": true,
        "controller": true,
        "kind": "Deployment",
        "name": "my-deployment",
        "uid": "123e4567-e89b-12d3-a456-426614174000"
      }
    ]
  }
}

After fix - ownerReference appears only once:

{
  "metadata": {
    "labels": {
      "app": "my-app",
      "version": "v1.0.0",
      "env": "prod"
    },
    "ownerReferences": [
      {
        "apiVersion": "apps/v1",
        "blockOwnerDeletion": true,
        "controller": true,
        "kind": "Deployment",
        "name": "my-deployment",
        "uid": "123e4567-e89b-12d3-a456-426614174000"
      }
    ]
  }
}

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 27, 2025
@k8s-ci-robot k8s-ci-robot requested review from apelisse and yliaog June 27, 2025 22:41
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 27, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @mrIncompetent. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 27, 2025
@alvaroaleman
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 30, 2025
@mrIncompetent mrIncompetent force-pushed the fix-extract-items-duplication branch from 34643c6 to 48e74cc Compare August 29, 2025 22:15
@mrIncompetent mrIncompetent force-pushed the fix-extract-items-duplication branch from 48e74cc to 0c56ef5 Compare September 10, 2025 22:14
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 10, 2025
@mrIncompetent
Copy link
Contributor Author

Ping @jpbetz and @liggitt

Copy link
Contributor

@jpbetz jpbetz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One readability suggestion then LGTM

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jpbetz, mrIncompetent

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 11, 2025
@mrIncompetent mrIncompetent force-pushed the fix-extract-items-duplication branch from 02eb440 to 3e9f11e Compare September 15, 2025 11:21
@mrIncompetent
Copy link
Contributor Author

Squashed the commits, did an additional renaming to improve readability.

ExtractItems with WithAppendKeyFields was duplicating atomic elements when extracting from associative lists. The item was processed twice: once for the direct path match and again for sub-path checking.
Added test with atomicElementList to verify the fix.

Co-authored-by: Joe Betz <[email protected]>
@mrIncompetent mrIncompetent force-pushed the fix-extract-items-duplication branch from 3e9f11e to e4bed54 Compare September 16, 2025 07:07
@mrIncompetent
Copy link
Contributor Author

Ping @jpbetz

1 similar comment
@mrIncompetent
Copy link
Contributor Author

Ping @jpbetz

@jpbetz
Copy link
Contributor

jpbetz commented Sep 18, 2025

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 18, 2025
@k8s-ci-robot k8s-ci-robot merged commit 1ba3aa6 into kubernetes-sigs:master Sep 18, 2025
6 checks passed
@mrIncompetent mrIncompetent deleted the fix-extract-items-duplication branch September 18, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants