FraunhoferIOSB / FAAAST-Service

FA³ST - Fraunhofer Advanced Asset Administration Shell Tools (for Digital Twins)
Other
59 stars 12 forks source link

PUT shells/[aasIdentifier]/submodels/[submodelIdentifier/submodel-elements/[idShortPath] fails for SubmodelElementList #930

Closed MMuellerMitsubishi closed 1 month ago

MMuellerMitsubishi commented 1 month ago

Describe the bug We have a submodel which uses the SubmodelElementList. There we want to update the information of one given submodel element in that list. When trying to do the PUT we get the following error:

{ "messages": [ { "messageType": "Exception", "text": "Range [1, 2) out of bounds for length 1", "code": "", "timestamp": "2024-10-17T13:18:31.075+00:00" } ] }

When we do a a GET on the same endpoint, the result is returned without an error

To Reproduce Steps to reproduce the behavior:

  1. Start the environment with a AAS and a SM that uses the SubmodelElementList
  2. Get the idShort Path of one element from the list
  3. Create the JSON body with the update information
  4. Call PUT shells/[aasIdentifier]/submodels/[submodelIdentifier/submodel-elements/[idShortPath]

Expected behavior SubmodelElement that is part of a list can be updated using the PUT method

Output see above

Additional context I can provide our initially loaded AAS environment and the exact request if you need it.

mjacoby commented 1 month ago

I tested the described behavior but was not able to reproduce the problem.

I used the following model


{
    "assetAdministrationShells": [
        {
            "idShort": "DemoAAS",
            "administration":
            {
                "version": "1",
                "revision": "0"
            },
            "id": "http://example.org/aas/1",
            "submodels": [
                {
                    "keys": [
                        {
                            "type": "Submodel",
                            "value": "http://example.org/submodel/1"
                        }
                    ]
                }
            ],
            "modelType": "AssetAdministrationShell"
        }
    ],
    "submodels": [
        {
            "idShort": "DemoSubmodel",
            "id": "http://example.org/submodel/1",
            "submodelElements": [
                {

                    "idShort": "list1",
                    "modelType": "SubmodelElementList",
                    "value": [
                        {
                            "idShort": "element0",
                            "valueType": "xs:double",
                            "modelType": "Property",
                            "value": "0"
                        },
                        {
                            "idShort": "element1",
                            "valueType": "xs:double",
                            "modelType": "Property",
                            "value": "1"
                        },
                        {
                            "idShort": "element2",
                            "valueType": "xs:double",
                            "modelType": "Property",
                            "value": "2"
                        }

                    ]
                }
            ],
            "kind": "Instance",
            "modelType": "Submodel"
        }
    ],
    "conceptDescriptions": []
}

And this request

PUT https://localhost/api/v3.0/shells/aHR0cDovL2V4YW1wbGUub3JnL2Fhcy8x/submodels/aHR0cDovL2V4YW1wbGUub3JnL3N1Ym1vZGVsLzE=/submodel-elements/list1.1

{
    "modelType": "Property",
    "valueType": "xs:double",
    "category": "Parameter",
    "idShort": "element1",
    "value": "10"
}

If you can provide me with the model and request you used I will look into this. You can post them either here or in case these might contain sensitive information you can also send them via email to faaast@iosb.fraunhofer.de.

MMuellerMitsubishi commented 1 month ago

Thanks for your quick response. In my model the properties that are part of the list do not have an idShort. Neither the ones in the submodel in the repos nor the one in the body of the PUT.

As I understood the AAS specification, there is no idShort the elements of an Submodel Element List. So I omitted them.

That's also what the AASX Package Explorer does when storing an AAS with a SML as JSON.

{ "assetAdministrationShells": [ { "id": "www.example.com/ids/sm/0095_3112_0142_2283", "assetInformation": { "assetKind": "Instance" }, "submodels": [ { "type": "ModelReference", "keys": [ { "type": "Submodel", "value": "www.example.com/ids/sm/0095_3112_0142_1583" } ] } ], "modelType": "AssetAdministrationShell" } ], "submodels": [ { "idShort": "SM", "id": "www.example.com/ids/sm/0095_3112_0142_1583", "submodelElements": [ { "idShort": "SML", "typeValueListElement": "SubmodelElement", "value": [ { "valueType": "xs:string", "value": "1", "modelType": "Property" }, { "valueType": "xs:string", "value": "2", "modelType": "Property" } ], "modelType": "SubmodelElementList" } ], "modelType": "Submodel" } ], "conceptDescriptions": [] }

mjacoby commented 1 month ago

You are correct, my initial test was incorrect as it was using idShort for elements in SubmodelElementList which is not allowed. I did test it again with the model you provided and I was not able to reproduce the error in your original post. However, I did find and fix an error that occurs when modifying a list that contains two elements that are exactly equal in all of their properties.

Could you please provide the REST requests needed to reproduce your problem?

If you like you can also try the latest version on the main branch either by manually compiling, using the latest SNAPSHOT jar file or the docker contrainer with tag latest. Maybe your problem has already been solved by the previous fix.

MMuellerMitsubishi commented 1 month ago

The issue is solved in latest snapshot that you have linked above. Before I was using the release 1.1.0.

So issue is solved. Thanks for the support.