#6225·kustomize

kustomize edit set image exponentially duplicates block-scalar content

Author: cresten-stclair-amplitudeCreated Aug 14, 2026Updated Aug 14, 2026
Labelskind/bugneeds-triage

What happened?

tldr: indented comments in transformers doubles the comments every time kustomize edit is called.

When a transformers literal block scalar immediately precedes images, lines beginning with # at the scalar indentation level are duplicated by every kustomize edit set image invocation.

These lines are scalar content—not YAML comments—so an image edit is unexpectedly modifying unrelated transformer content.

The growth is exponential, including when the exact same image update is repeated:

1 -> 2 -> 4 -> 8 -> 16

This can cause a small kustomization file to grow without limit in automated image-update workflows.

This appears related to #4481, but the exponential amplification on repeated edits seems distinct.

Public reproduction: https://github.com/cresten-stclair-amplitude/kustomize-comment-duplication-repro

What did you expect to happen?

kustomize edit set image should update the matching image entry without changing unrelated literal block-scalar content.

Repeating the same image update should be byte-idempotent, and the marker count should remain 1.

How can we reproduce it (as minimally and precisely as possible)?

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

transformers:
- |-
  apiVersion: widgets.example.com/v1
  kind: ExampleTransformer
  metadata:
    name: example-transformer
  owner: ExampleTeam
  service: example-service
  version: EXAMPLE
  # REPRODUCTION-MARKER: publish the example image before updating this tag.
  # This synthetic comment doubles when the image tag is updated repeatedly.

images:
- name: example-service
  newTag: example-old
bash
git clone https://github.com/cresten-stclair-amplitude/kustomize-comment-duplication-repro.git
cd kustomize-comment-duplication-repro
./reproduce.sh

Expected output

yaml
initial: expected=1 actual=1
run 1:   expected=1 actual=1
run 2:   expected=1 actual=1
run 3:   expected=1 actual=1
run 4:   expected=1 actual=1

Actual output

yaml
initial: expected=1 actual=1
run 1:   expected=2 actual=2
run 2:   expected=4 actual=4
run 3:   expected=8 actual=8
run 4:   expected=16 actual=16
run 5:   expected=32 actual=32
run 6:   expected=64 actual=64
run 7:   expected=128 actual=128
run 8:   expected=256 actual=256
run 9:   expected=512 actual=512
run 10:   expected=1024 actual=1024
run 11:   expected=2048 actual=2048
run 12:   expected=4096 actual=4096
run 13:   expected=8192 actual=8192
run 14:   expected=16384 actual=16384
run 15:   expected=32768 actual=32768
run 16:   expected=65536 actual=65536

Kustomize version

v5.8.1

Operating system

MacOS

Source: kubernetes-sigs/kustomize