Skip to content

Bug: Wildcard patches are not applied to all items when target key exists only in some objects #3107

@d-enk

Description

@d-enk

Description

When using profile patches with a wildcard path (e.g. images.*.docker), the patch is applied only to items where the target key already exists, if at least one item explicitly defines this key in the base config.

This happens for both op: replace and op: add.

As a result, items that do not define the key are skipped, even though the wildcard path matches them logically.


DevSpace version

DevSpace version : 6.3.18

Reproducible example

version: v2beta1
name: test

profiles:
  - name: use_docker_cli
    patches:
      - op: replace
        path: images.*.docker
        value:
          useCli: true
      # same behavior with:
      # - op: add

images:
  image1:
    image: image1
    docker: {}

  image2:
    image: image2

Command

devspace print -p use_docker_cli --skip-info

Actual behavior

images:
  image1:
    image: image1
    docker:
      useCli: true
  image2:
    image: image2

🔴 docker.useCli is not added to image2.


Expected behavior

images:
  image1:
    image: image1
    docker:
      useCli: true
  image2:
    image: image2
    docker:
      useCli: true

The wildcard patch should be applied to all images, regardless of whether docker was defined in the base config.


Additional observation

If docker is removed from all images in the base config:

images:
  image1:
    image: image1
  image2:
    image: image2

Then the same patch works correctly and creates docker.useCli for both images.


Why this is problematic

  • Wildcard patches behave inconsistently depending on base config shape
  • op: add and op: replace do not create missing keys when mixed with existing ones
  • Makes it difficult to apply global defaults via profiles

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions