fix(registry): prevent NullPointerException when specificAssetIds is null in DiscoveryIntegrationAasRegistry #887
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix(registry): add null safety for descriptor, and specificAssetIds in DiscoveryIntegrationAasRegistry
Description of Changes
This pull request fixes a
NullPointerExceptionthat occurred in the Digital Twin Registry when posting or replacing an AAS descriptor without providingspecificAssetIds.Root Cause
In the class
org.eclipse.digitaltwin.basyx.aasregistry.feature.discovery.integration.DiscoveryIntegrationAasRegistry,both
insertAasDescriptor()andreplaceAasDescriptor()methods called:without verifying whether
descr,globalAssetId, orspecificAssetIdswerenull.When an incoming AAS descriptor did not include these fields, the application threw a
NullPointerExceptionand returned HTTP 500 instead of the expected HTTP 201 Created.Solution Implemented
specificAssetIdslistspecificAssetIdsare missing.specificAssetIdsusingList.of()to avoid null propagation.This ensures that:
Related Issue
[BUG] DTR responds with HTTP500 on valid request #886
Closes #886
BaSyx Configuration for Testing
The issue and fix were verified using a local Docker setup:
No additional configuration required.
Test Procedure
AAS Files Used for Testing
No AAS files required — testing performed via REST API requests with minimal descriptor payloads such as:
{ "id": "simple-shell" }Optional verification with descriptor including asset identifiers:
{ "id": "urn:uuid:e5c96ab5-896a-1234-8761-efd74777ca97", "idShort": "myAas", "specificAssetIds": [ { "name": "manufacturerPartId", "value": "123-345-567103" } ], "submodelDescriptors": [ { "id": "e5c96ab5-896a-482c-8761-efd74777ca97", "semanticId": { "type": "ExternalReference", "keys": [ { "type": "GlobalReference", "value": "urn:bamm:io.catenax.material_for_recycling:1.1.0#MaterialForRecycling" } ] }, "endpoints": [ { "interface": "SUBMODEL-3.0", "protocolInformation": { "href": "https://edc.data.plane/mypath/submodel", "endpointProtocol": "HTTP", "endpointProtocolVersion": [ "1.1" ], "subprotocol": "DSP", "subprotocolBody": "id=123;dspEndpoint=http://edc.control.plane/api/v1/dsp", "subprotocolBodyEncoding": "plain", "securityAttributes": [ { "type": "NONE", "key": "NONE", "value": "NONE" } ] } } ] } ] }Both payloads confirm stable operation with and without identifiers.
Additional Information
DiscoveryIntegrationUtils) to encapsulate the null-safe extraction and mapping logic, reducing duplication across registry methods.✅ Tested environments: