Skip to content

[overlay] incorrectly concatenates enum arrays during deep merge #792

@garciasdos

Description

@garciasdos

Description

When using bump overlay to apply an overlay that adds new properties to a schema, enum arrays from nested properties are incorrectly appended to existing enum arrays at different paths, resulting in duplicate values.

Environment

  • bump-cli version: 2.9.8
  • Node.js version: 24.x

Steps to Reproduce

  1. Have an OpenAPI spec with a property containing an enum:
# base-spec.yaml
paths:
  /items/{id}:
    put:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                method:
                  type: string
                  enum: [GET, POST, PUT, DELETE]
  1. Apply an overlay that adds a nested object with a property of the same name:
# overlay.yaml
overlay: 1.0.0
actions:
  - target: $.paths['/items/{id}'].put.requestBody.content['application/json'].schema.properties
    update:
      request:
        type: object
        properties:
          method:
            type: string
            enum: [GET, POST, PUT, DELETE]
  1. Run: bump overlay base-spec.yaml overlay.yaml

Expected Behavior

The top-level method.enum should remain unchanged with 4 values:

method:
  enum: [GET, POST, PUT, DELETE]

And a new request.properties.method.enum should be added with 4 values.

Actual Behavior

The top-level method.enum is incorrectly modified to have 8 values (duplicated):

method:
  enum: [GET, POST, PUT, DELETE, GET, POST, PUT, DELETE]

Root Cause

In src/core/overlay.ts, the update method uses mergician with appendArrays: true:

const merger = mergician({ appendArrays: true });

This causes arrays to be concatenated during deep merge. When the overlay adds a nested property with the same name (method) containing an enum array, mergician appears to find and concatenate enum arrays from different schema paths.

Suggested Fix

#791

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions