eclipse-tractusx / item-relationship-service

https://eclipse-tractusx.github.io/item-relationship-service/docs/
Apache License 2.0
7 stars 21 forks source link

Relationships and SubmodelDescriptors are emtpy without defining SerialPart aspect in the Digital Twin #193

Closed saudkhan116 closed 10 months ago

saudkhan116 commented 11 months ago

Introduction

We found an issue while utilizing the IRS-API component. We didn't register the SerialPart aspect model and we get empty relationships in the IRS job response. When we define the SeirialPart submodel, we are able to retreive the relationships and submodelDescriptors.

Problem Description

Job Request

{
    "aspects": [],
    "bomLifecycle": "asBuilt",
    "lookupBPNs": false,
    "collectAspects": false,
    "direction": "downward",
    "depth": 2,
    "integrityCheck": false,
    "callbackUrl": "https://materialpass.int.demo.catena-x.net/api/irs/endpoint?id=urn:uuid:efcb5f8d-f31c-4b1f-b090-9c878054554d&state=COMPLETED",
    "key": {
        "globalAssetId": "urn:uuid:efcb5f8d-f31c-4b1f-b090-9c878054554d",
        "bpn": "BPNL00000000CBA5"
    }
}

Job Response

Here is the response payload of the IRS Job which does not contain relationships and submodelDescriptors. In the original digital twin, there is battery digital product passport and BOMasBuilt aspect models but not a SerialPart aspect defined.

{
    "job": {
        "id": "158f8c65-1129-45e2-a961-41246d350a24",
        "globalAssetId": "urn:uuid:efcb5f8d-f31c-4b1f-b090-9c878054554d",
        "state": "COMPLETED",
        "exception": null,
        "createdOn": "2023-10-17T07:15:25.208248481Z",
        "startedOn": "2023-10-17T07:15:25.208349181Z",
        "lastModifiedOn": "2023-10-17T07:18:48.292828187Z",
        "completedOn": "2023-10-17T07:18:48.292830387Z",
        "owner": "sa241",
        "summary": {
            "asyncFetchedItems": {
                "running": 0,
                "completed": 1,
                "failed": 0
            },
            "bpnLookups": {
                "completed": 0,
                "failed": 0
            }
        },
        "parameter": {
            "bomLifecycle": "asBuilt",
            "aspects": [
                "SerialPart"
            ],
            "depth": 1,
            "bpn": "BPNL00000000CBA5",
            "direction": "downward",
            "collectAspects": false,
            "lookupBPNs": false,
            "callbackUrl": "https://materialpass.int.demo.catena-x.net/api/irs/endpoint?id=urn:uuid:efcb5f8d-f31c-4b1f-b090-9c878054554d&state=COMPLETED"
        }
    },
    "relationships": [],
    "shells": [
        {
            "administration": null,
            "description": [
                {
                    "language": "en",
                    "text": "Battery Digital Twin"
                }
            ],
            "globalAssetId": "urn:uuid:efcb5f8d-f31c-4b1f-b090-9c878054554d",
            "idShort": "Battery_BAT-XYZ789",
            "id": "urn:uuid:3d050cd8-cdc7-4d65-9f37-70a65d5f53f5",
            "specificAssetIds": [
                {
                    "name": "partInstanceId",
                    "subjectId": null,
                    "value": "BAT-XYZ789",
                    "semanticId": null
                }
            ],
            "submodelDescriptors": []
        }
    ],
    "tombstones": [],
    "submodels": [],
    "bpns": []
}

Working Solution

When the SerialPart aspect was included in a digital twin, the IRS retrieves asuccessful payload with relationships and submodelDescriptors:

{
    "job": {
        "id": "85fdb5fe-0335-4336-88c4-0bb482f4f27f",
        "globalAssetId": "urn:uuid:efcb5f8d-f31c-4b1f-b090-9c878054554d",
        "state": "COMPLETED",
        "exception": null,
        "createdOn": "2023-10-17T12:09:02.345527235Z",
        "startedOn": "2023-10-17T12:09:02.345647035Z",
        "lastModifiedOn": "2023-10-17T12:19:05.558064531Z",
        "completedOn": "2023-10-17T12:19:05.558065431Z",
        "owner": "sa241",
        "summary": {
            "asyncFetchedItems": {
                "running": 0,
                "completed": 3,
                "failed": 0
            },
            "bpnLookups": {
                "completed": 0,
                "failed": 0
            }
        },
        "parameter": {
            "bomLifecycle": "asBuilt",
            "aspects": [
                "SerialPart"
            ],
            "depth": 2,
            "bpn": "BPNL00000000CBA5",
            "direction": "downward",
            "collectAspects": false,
            "lookupBPNs": false,
            "callbackUrl": "https://materialpass.int.demo.catena-x.net/api/irs/endpoint?id=urn:uuid:efcb5f8d-f31c-4b1f-b090-9c878054554d&state=COMPLETED"
        }
    },
    "relationships": [
        {
            "catenaXId": "urn:uuid:efcb5f8d-f31c-4b1f-b090-9c878054554d",
            "linkedItem": {
                "quantity": {
                    "quantityNumber": 5.0,
                    "measurementUnit": {
                        "datatypeURI": null,
                        "lexicalValue": "piece"
                    }
                },
                "lifecycleContext": "asBuilt",
                "assembledOn": "2023-01-09T17:26:54.709Z",
                "lastModifiedOn": "2023-01-09T17:26:54.709Z",
                "childCatenaXId": "urn:uuid:d8ec6acc-1ad7-47b4-bc7e-612122d9d552"
            },
            "aspectType": "SingleLevelBomAsBuilt",
            "bpn": "BPNL00000000CBA5"
        },
        {
            "catenaXId": "urn:uuid:d8ec6acc-1ad7-47b4-bc7e-612122d9d552",
            "linkedItem": {
                "quantity": {
                    "quantityNumber": 100.0,
                    "measurementUnit": {
                        "datatypeURI": null,
                        "lexicalValue": "piece"
                    }
                },
                "lifecycleContext": "asBuilt",
                "assembledOn": "2023-01-09T17:26:54.709Z",
                "lastModifiedOn": "2023-01-09T17:26:54.709Z",
                "childCatenaXId": "urn:uuid:63b95496-86ed-4762-b248-491d5c1242e1"
            },
            "aspectType": "SingleLevelBomAsBuilt",
            "bpn": "BPNL00000000CBA5"
        }
    ],
    "shells": [
        {
            "administration": null,
            "description": [],
            "globalAssetId": "urn:uuid:efcb5f8d-f31c-4b1f-b090-9c878054554d",
            "idShort": "Battery",
            "id": "urn:uuid:4395dd9a-6877-4a09-889e-695c9aa0ce90",
            "specificAssetIds": [
                {
                    "name": "manufacturerId",
                    "subjectId": null,
                    "value": "BPNL00000000CBA5",
                    "semanticId": null
                },
                {
                    "name": "partInstanceId",
                    "subjectId": null,
                    "value": "BAT-XYZ789",
                    "semanticId": null
                },
                {
                    "name": "manufacturerPartId",
                    "subjectId": null,
                    "value": "BPNL00000000CBA5",
                    "semanticId": null
                }
            ],
            "submodelDescriptors": [
                {
                    "administration": null,
                    "description": [],
                    "idShort": "SerialPart",
                    "id": "urn:uuid:2e67dc3c-6de4-494c-8a08-9f851514f106",
                    "semanticId": {
                        "keys": [
                            {
                                "value": "urn:bamm:io.catenax.serial_part:1.0.1#SerialPart",
                                "type": "GlobalReference"
                            }
                        ],
                        "type": "ExternalReference"
                    },
                    "endpoints": [
                        {
                            "protocolInformation": {
                                "href": "https://materialpass.int.demo.catena-x.net/BPNL000000000000/api/public/data/urn:uuid:2e67dc3c-6de4-494c-8a08-9f851514f106",
                                "endpointProtocol": "HTTP",
                                "endpointProtocolVersion": [
                                    "1.1"
                                ],
                                "subprotocol": "DSP",
                                "subprotocolBody": "id=urn:uuid:64b34971-f3b7-4540-95d7-5db85883f0cf;dspEndpoint=https://materialpass.int.demo.catena-x.net/BPNL000000000000",
                                "subprotocolBodyEncoding": "plain"
                            },
                            "interface": "SUBMODEL-3.0"
                        }
                    ]
                }
            ]
        },
        {
            "administration": null,
            "description": [],
            "globalAssetId": "urn:uuid:d8ec6acc-1ad7-47b4-bc7e-612122d9d552",
            "idShort": "BatteryPack",
            "id": "urn:uuid:958e68d6-8c72-4833-ac50-3962b10e4c0e",
            "specificAssetIds": [
                {
                    "name": "manufacturerId",
                    "subjectId": null,
                    "value": "BPNL00000000CBA5",
                    "semanticId": null
                },
                {
                    "name": "partInstanceId",
                    "subjectId": null,
                    "value": "EVPACK-TRJ712",
                    "semanticId": null
                },
                {
                    "name": "manufacturerPartId",
                    "subjectId": null,
                    "value": "BPNL00000000CBA5",
                    "semanticId": null
                }
            ],
            "submodelDescriptors": [
                {
                    "administration": null,
                    "description": [],
                    "idShort": "SerialPart",
                    "id": "urn:uuid:8926dc68-43f8-4782-bda2-1cd23ecab0ad",
                    "semanticId": {
                        "keys": [
                            {
                                "value": "urn:bamm:io.catenax.serial_part:1.0.1#SerialPart",
                                "type": "GlobalReference"
                            }
                        ],
                        "type": "ExternalReference"
                    },
                    "endpoints": [
                        {
                            "protocolInformation": {
                                "href": "https://materialpass.int.demo.catena-x.net/BPNL000000000000/api/public/data/urn:uuid:8926dc68-43f8-4782-bda2-1cd23ecab0ad",
                                "endpointProtocol": "HTTP",
                                "endpointProtocolVersion": [
                                    "1.1"
                                ],
                                "subprotocol": "DSP",
                                "subprotocolBody": "id=urn:uuid:64b34971-f3b7-4540-95d7-5db85883f0cf;dspEndpoint=https://materialpass.int.demo.catena-x.net/BPNL000000000000",
                                "subprotocolBodyEncoding": "plain"
                            },
                            "interface": "SUBMODEL-3.0"
                        }
                    ]
                }
            ]
        },
        {
            "administration": null,
            "description": [],
            "globalAssetId": "urn:uuid:63b95496-86ed-4762-b248-491d5c1242e1",
            "idShort": "CellModule",
            "id": "urn:uuid:42ac8218-716b-4f95-81b8-2adb3b6cd0aa",
            "specificAssetIds": [
                {
                    "name": "partInstanceId",
                    "subjectId": null,
                    "value": "CTA-13123",
                    "semanticId": null
                },
                {
                    "name": "manufacturerId",
                    "subjectId": null,
                    "value": "BPNL00000000CBA5",
                    "semanticId": null
                },
                {
                    "name": "manufacturerPartId",
                    "subjectId": null,
                    "value": "BPNL00000000CBA5",
                    "semanticId": null
                }
            ],
            "submodelDescriptors": [
                {
                    "administration": null,
                    "description": [],
                    "idShort": "DigitalProductPassport",
                    "id": "urn:uuid:6d4dc211-b775-4b76-899b-16a7f95bdf2d",
                    "semanticId": {
                        "keys": [
                            {
                                "value": "urn:bamm:io.catenax.generic.digital_product_passport:1.0.0#DigitalProductPassport",
                                "type": "GlobalReference"
                            }
                        ],
                        "type": "ExternalReference"
                    },
                    "endpoints": [
                        {
                            "protocolInformation": {
                                "href": "https://materialpass.int.demo.catena-x.net/BPNL000000000000/api/public/data/urn:uuid:6d4dc211-b775-4b76-899b-16a7f95bdf2d",
                                "endpointProtocol": "HTTP",
                                "endpointProtocolVersion": [
                                    "1.1"
                                ],
                                "subprotocol": "DSP",
                                "subprotocolBody": "id=urn:uuid:64b34971-f3b7-4540-95d7-5db85883f0cf;dspEndpoint=https://materialpass.int.demo.catena-x.net/BPNL000000000000",
                                "subprotocolBodyEncoding": "plain"
                            },
                            "interface": "SUBMODEL-3.0"
                        }
                    ]
                },
                {
                    "administration": null,
                    "description": [],
                    "idShort": "SingleLevelUsageAsBuilt",
                    "id": "urn:uuid:6d68a1ed-3051-4847-abe6-83500f5f9e23",
                    "semanticId": {
                        "keys": [
                            {
                                "value": "urn:bamm:io.catenax.single_level_usage_as_built:1.0.1#SingleLevelUsageAsBuilt",
                                "type": "GlobalReference"
                            }
                        ],
                        "type": "ExternalReference"
                    },
                    "endpoints": [
                        {
                            "protocolInformation": {
                                "href": "https://materialpass.int.demo.catena-x.net/BPNL000000000000/api/public/data/urn:uuid:6d68a1ed-3051-4847-abe6-83500f5f9e23",
                                "endpointProtocol": "HTTP",
                                "endpointProtocolVersion": [
                                    "1.1"
                                ],
                                "subprotocol": "DSP",
                                "subprotocolBody": "id=urn:uuid:64b34971-f3b7-4540-95d7-5db85883f0cf;dspEndpoint=https://materialpass.int.demo.catena-x.net/BPNL000000000000",
                                "subprotocolBodyEncoding": "plain"
                            },
                            "interface": "SUBMODEL-3.0"
                        }
                    ]
                },
                {
                    "administration": null,
                    "description": [],
                    "idShort": "SerialPart",
                    "id": "urn:uuid:43445820-8703-494e-b2dc-ea733d14bf42",
                    "semanticId": {
                        "keys": [
                            {
                                "value": "urn:bamm:io.catenax.serial_part:1.0.1#SerialPart",
                                "type": "GlobalReference"
                            }
                        ],
                        "type": "ExternalReference"
                    },
                    "endpoints": [
                        {
                            "protocolInformation": {
                                "href": "https://materialpass.int.demo.catena-x.net/BPNL000000000000/api/public/data/urn:uuid:43445820-8703-494e-b2dc-ea733d14bf42",
                                "endpointProtocol": "HTTP",
                                "endpointProtocolVersion": [
                                    "1.1"
                                ],
                                "subprotocol": "DSP",
                                "subprotocolBody": "id=urn:uuid:64b34971-f3b7-4540-95d7-5db85883f0cf;dspEndpoint=https://materialpass.int.demo.catena-x.net/BPNL000000000000",
                                "subprotocolBodyEncoding": "plain"
                            },
                            "interface": "SUBMODEL-3.0"
                        }
                    ]
                },
                {
                    "administration": null,
                    "description": [],
                    "idShort": "SingleLevelBomAsBuilt",
                    "id": "urn:uuid:bbb3b8ca-ff9a-46b0-873f-087d7e42bbfd",
                    "semanticId": {
                        "keys": [
                            {
                                "value": "urn:bamm:io.catenax.single_level_bom_as_built:1.0.0#SingleLevelBomAsBuilt",
                                "type": "GlobalReference"
                            }
                        ],
                        "type": "ExternalReference"
                    },
                    "endpoints": [
                        {
                            "protocolInformation": {
                                "href": "https://materialpass.int.demo.catena-x.net/BPNL000000000000/api/public/data/urn:uuid:bbb3b8ca-ff9a-46b0-873f-087d7e42bbfd",
                                "endpointProtocol": "HTTP",
                                "endpointProtocolVersion": [
                                    "1.1"
                                ],
                                "subprotocol": "DSP",
                                "subprotocolBody": "id=urn:uuid:64b34971-f3b7-4540-95d7-5db85883f0cf;dspEndpoint=https://materialpass.int.demo.catena-x.net/BPNL000000000000",
                                "subprotocolBodyEncoding": "plain"
                            },
                            "interface": "SUBMODEL-3.0"
                        }
                    ]
                }
            ]
        }
    ],
    "tombstones": [],
    "submodels": [],
    "bpns": []
}

I hope this helps. If you need anything please let me know.

Thank you!

Kind Regards, DPP Team

jzbmw commented 11 months ago

Hints

Acceptance Criteria

ds-ext-kmassalski commented 10 months ago

@saudkhan116 I was not able to reproduce the issue. I registered a Shell without SerialPart submodel descriptor in DTR service, and then started a Job in IRS, and it collected relationships successfully. Can you check one more time and potentially provide some more details?

ds-alexander-bulgakov commented 10 months ago

Hints

  • One possible Solution: API Refactoring - change the default value for aspect types to an empty list.
  • Expected Behaviour with an empty aspect types list:
  • if the array of aspect types is empty --> no aspect models will be collected and the process will run only on the relationTypeAspects

Acceptance Criteria

  • [ ] aspects Schema in the API documentation has been refactored
  • [x] A tavern or cucumber test has been created for this behaviour to tested
  • [ ] Behaviour has been verfied
  • [ ] Bug is fixed
  • [ ] Bug is mitigated and documented in Github

Tavern test has been adjusted and check methods added for expected behaviour:

Changes are pushed to branch "feature/TRI-1658-infected-supply-chain-on-first-tier-level"

ds-ext-kmassalski commented 10 months ago

Default behavour changes, PR merged: https://github.com/catenax-ng/tx-item-relationship-service/pull/655

saudkhan116 commented 10 months ago

@saudkhan116 I was not able to reproduce the issue. I registered a Shell without SerialPart submodel descriptor in DTR service, and then started a Job in IRS, and it collected relationships successfully. Can you check one more time and potentially provide some more details?

Hi @ds-ext-kmassalski, Thank you for your reply. Unfortunately, I could not execute the IRS job to reproduce this issue and provide you more details at the moment. I get "ACCESS DENIED", I think this is the problem of authentication with the MIW on INT.

jzbmw commented 10 months ago

@saudkhan116 since MIW is resolved, could you reproduce this behaviour?

jzbmw commented 10 months ago

we implemented this.

saudkhan116 commented 10 months ago

@saudkhan116 since MIW is resolved, could you reproduce this behaviour?

Hi @jzbmw, IRS doesn't work because of the keycloak configuration changes in version 4.1.0 (from the centrally managed keycloak in Portal), unfortunately we cannot reproduce the issue as long as the IRS works again.

saudkhan116 commented 9 months ago

Everything works as expected, thanks 👍