eclipse-edc/Connector

`Consumer-Asset` with the same ID as a `Provider-Asset` Cannot Be Deleted After Contract Negotiation

Opened this issue · 2 comments

Bug Report

Describe the Bug

After a Contract for an Asset of a Provider has successfully been negotiated, an Asset reciding at the Consumer with the same ID and not being part of a Contract, can not be deleted anymore.

Expected Behavior

Asset can be deleted, because it has not been part of a contract.

Observed Behavior

Asset can't be deleted.

Steps to Reproduce

  1. Create and negotiate a Contract for Asset-A reciding at the Provider
  2. Create Asset-B with the same ID as Asset-A at the Consumer
  3. Try to delete Asset-B using the Management-API

Context Information

  • Used version: v0.7.2

Possible Implementation

Query just for Assets with ContractNegotations of type PROVIDER in the AssetServiceImpl.

var query = QuerySpec.Builder.newInstance()
.filter(List.of(new Criterion(ASSET_ID_QUERY, "=", assetId)))
.build();
try (var negotiationsOnAsset = contractNegotiationStore.queryNegotiations(query)) {
if (negotiationsOnAsset.findAny().isPresent()) {
return ServiceResult.conflict(format("Asset %s cannot be deleted as it is referenced by at least one contract agreement", assetId));
}
}

This should never happen because the identifier of the dataset (asset)

is a text string which is assigned to the resource to provide an unambiguous reference within a particular context.

(ref.)

this is an edge case that won't get prioritized, but we're open to contributions in form of PR.

Thanks @ndr-brt for clarification. Yes, we will take care of fixing it and provide a PR.
@ununhexium @AbdullahMuk