Skip to content

Merging a vendor, component, or release into itself silently deletes it #4519

Description

@kavya685

Description

mergeVendors, mergeComponents, and mergeReleases in VendorDatabaseHandler.java and ComponentDatabaseHandler.java do not guard against mergeTargetId and mergeSourceId when they have same ID. When both IDs refer to the same document, the method still runs its normal merge steps (update target, repoint references, delete source) and unconditionally deletes the source at the end, since target and source are the same document, this silently deletes the vendor/component/release the caller intended to keep, while still returning RequestStatus.SUCCESS.

How to reproduce

  1. Create a vendor (or component, or release) and note its ID, e.g. V1.

  2. Call the merge endpoint/method with the same ID as both target and source:
    mergeVendors(mergeTargetId="V1", mergeSourceId="V1", mergeSelection, user)

  3. Observe the response: RequestStatus.SUCCESS.

  4. Attempt to fetch V1 afterward, it no longer exists.

The same reproduction steps apply to mergeComponents and mergeReleases

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions