Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling of assetids in /lookup/shells endpoint #201

Closed
arnoweiss opened this issue Aug 23, 2023 · 12 comments
Closed

Incorrect handling of assetids in /lookup/shells endpoint #201

arnoweiss opened this issue Aug 23, 2023 · 12 comments
Assignees

Comments

@arnoweiss
Copy link

Just like the AAS-Registry-API in #154 - the lookup API behaves similarly incorrect wrt encoding ids.

In AAS Pt. 2, p. 113, point 13 it says:

When retrieving AssetAdministrationShells (/shells, /lookup/shells), a query parameter “?assetids=” can be specified. Such assetId may be a globalAssetId or specificAssetId. The corresponding key-value-pair is first serialized to JSON and then base64url-encoded. The resulting encoded string is the value of “?assetids=”

Since the swagger files are incorrect too, this is probably an interpretation that should first be confirmed by someone knowledgeable from the IDTA. I've opened an issue here: admin-shell-io/aas-specs-api#162

Reproduce

  1. Create any shell-descriptor incl specficAssetIds
POST /api/v3.0/shell-descriptors HTTP/1.1
Host: mydtr.com
Content-Type: application/json
Accept: application/json
Authorization: Bearer mytoken
Content-Length: 241

{
    "description": [],
    "displayName": [],
    "idShort": "myAas",
    "id": "urn:uuid:myAasId",
    "specificAssetIds": [
        {
            "name": "myId",
            "value": "foo"
        }
    ],
    "submodelDescriptors": []
}

The specificAssetId is encoded to eyJuYW1lIjogIm15SWQiLCJ2YWx1ZSI6ICJmb28ifQ.

  1. lookup the assetId
GET /api/v3.0/lookup/shells?assetIds=eyJuYW1lIjogIm15SWQiLCJ2YWx1ZSI6ICJmb28ifQ HTTP/1.1
Host: mydtr.com
Accept: application/json
Authorization: Bearer 

expected

HTTP 200

{
    "paging_metadata": {},
    "result": [
        "urn:uuid:myAasId"
    ]
}

actual

HTTP 400

{
    "messages": [
        {
            "messageType": "Error",
            "text": "The provided parameters are invalid. assetIds=eyJuYW1lIjogIm15SWQiLCJ2YWx1ZSI6ICJmb28ifQ"
        }
    ]
}
@agg3fe
Copy link
Contributor

agg3fe commented Aug 25, 2023

Hi @arnoweiss , currently we have implemented version 3.0 for lookup API. Since your test is based on 3.0.1 version, we will implement this in future and will update you about it. Thanks

@arnoweiss
Copy link
Author

arnoweiss commented Aug 25, 2023

Hi @agg3fe - thanks for your reply. The encoding was already part of v3.0.0 of the spec, see here. I understand that this is a breaking change in the implementation and thus must be handled with care. Still, it should be treated independently of the upgrade to v3.0.1.

@agg3fe
Copy link
Contributor

agg3fe commented Sep 27, 2023

Hi @arnoweiss We will be taking this in the next sprint starting next week. will update you once we release this.

@arnoweiss
Copy link
Author

This is still unresolved. A change to comply with the spec will break many consumer-workflows, so please be mindful about communicating it.

@arnoweiss
Copy link
Author

This was fixed, right?

@agg3fe
Copy link
Contributor

agg3fe commented Mar 11, 2024

This was fixed, right?

Hi @arnoweiss, Yes this was fixed and released already previously.

@arnoweiss
Copy link
Author

Thanks, I'll close the ticket. I'd be great if the maintainers of sldt-digital-twin-registry paid closer attention to the github-issues. Users will assume that a bug is unfixed if the corresponding ticket remains open.

@FaridLU
Copy link

FaridLU commented Sep 4, 2024

Dear @arnoweiss, can you please help me out with the aasidentifier. By following the documentation I was able to create shelldescriptors. To get specific shell-descriptor, it requires aasidentifier. I spent a lot of time to find a way to get this. Can you please help me with that?

@arnoweiss
Copy link
Author

Depending on the deployment, you may not be able to GET a certain resource because of access control measures that your admin configured - see the docs on access control.

@FaridLU
Copy link

FaridLU commented Sep 6, 2024

@arnoweiss Thanks for the comment. I really appreciate. I have figured out the aasidentifier thing. Currently, I am stuck on something, which is the following:

When I hit this endpoint {{baseUrl}}/api/v3/lookup/shells?assetIds=[{"name":"oen","value":"1239485"},{"name":"manufacturePartId","value":"1234"}], the assetIds (in the API documentation) should be a list of dictionary. Which throws an error when we do that. According to the backend code, it says to provide encoded string. Could you please tell me which section of the current URL (that I provided earlier) should I encode and pass that in the assetIds section?

Thanks in advance..

@arnoweiss
Copy link
Author

I think it's implemented in such a way that for each specificAssetId

  1. it is serialized as full json object
  2. base64url encoded
  3. attached via separate query parameter with key assetIds

resulting in (admittedly weird-looking) requests like /lookup/shells?assetIds=abc&assetIds=def

@FaridLU
Copy link

FaridLU commented Sep 6, 2024

@arnoweiss Thank you very much for providing such a thorough explanation. Your guidance proved to be effective, just as you assured me it would. Your time and effort are greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants