commercetools-jvm-sdk icon indicating copy to clipboard operation
commercetools-jvm-sdk copied to clipboard

io.sphere.sdk.products.commands.updateactions.SetAssetKey doesn't work as expected

Open mim-foryouandyourcustomers opened this issue 3 years ago • 1 comments

Describe the bug io.sphere.sdk.products.commands.updateactions.SetAssetKey class from java SDK doesn't do what its name suggests. The Update Actions created based on this class delete the Asset rather than updating the Key

To Reproduce Try to update the key of any existing Asset on Product with this code. SetAssetKey.ofVariantId(assetId, productVarianttId, newAssetKey);

Expected behavior The Asset is updated , the new key is newAssetKey

Screenshots/Code snippet The action string is hardcoded in the constructor, however it is wrong. It should be setAssetKey instead of removeAsset

public final class SetAssetKey extends StagedProductUpdateActionImpl<Product> {
  @Nullable
  private final Integer variantId;
  @Nullable
  private final String sku;
  private final String assetId;
  private final String assetKey;

  private SetAssetKey(final String assetId, final String assetKey, @Nullable final Integer variantId, @Nullable final String sku, @Nullable final Boolean staged) {
    super("removeAsset", staged);
    this.assetId = assetId;
    this.assetKey = assetKey;
    this.variantId = variantId;
    this.sku = sku;
  }

Stack information (please complete the following information):

  • Java: 17
  • SDK: v1.62.0 I tried upgrading to the latest version of commercetools SDK - it didn't help

Moved the issue to the correct repository.

And yes it's a typo. Thanks for the report 👍

jenschude avatar Feb 08 '22 20:02 jenschude