Endorsment Issue with Askar 0.7.4
encountered some problems in an endorsement request for a credential definitions from an acapy 0.7.4 "askar" author to an acapy 0.7.4 "indy" endorser.
We found there is at least one difference between the indy message_attached and the askar message_attached : when an endorsment request is sent.
Following an example:
Indy message_attach: "messages_attach": [{"@id": "df27eed3-bd73-4bb3-b778-6272f6a9c06a", "mime-type": "application/json", "data": {"json": "{"endorser":"","identifier":"","operation":{"data":{"primary":{"n":"900866316706900826505487380142019186833215536243306998523711840080686962535129521871807709456958294731885367630109461989184974934135431277920077052637284007362073256302773373790155467271483537593872277138492900647736560457729613803045823615839461779352121757141654245087268342283609682884461246069997159223494219482801856209924475135643986173625188680684081986284741788405442381084469835966686471368000346266336930578753487736958587973099736700363370029225367518042266075
askar message_attach: "messages_attach": [{"@id": "d7807f38-cbbf-46cd-8350-bb93634acd96", "mime-type": "application/json", "data": {"json": {"endorser": "", "identifier": "", "operation": {"data": {"primary": {"n": "11012204772774227617134749947936127212235724731372246056852236704544263095374077853804694519166464500768014389483519132777
One is a string json and the other is a dict. And this is consistent with the errore reporter from the endorser :
_2022-09-30 10:26:53,163 aiohttp.server ERROR Error handling request Traceback (most recent call last): File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request resp = await request_handler(request) File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/home/indy/aries_cloudagent/admin/server.py", line 171, in ready_middleware return await handler(request) File "/home/indy/aries_cloudagent/admin/server.py", line 208, in debug_middleware return await handler(request) File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/site-packages/aiohttp_apispec/middlewares.py", line 45, in validation_middleware return await handler(request) File "/home/indy/aries_cloudagent/admin/server.py", line 328, in check_token return await handler(request) File "/home/indy/aries_cloudagent/admin/server.py", line 420, in setup_context return await task File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup future.result() File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/asyncio/tasks.py", line 182, in _step result = coro.throw(exc) File "/home/indy/aries_cloudagent/protocols/endorse_transaction/v1_0/routes.py", line 356, in endorse_transaction_response use_endorser_did=endorser_did, File "/home/indy/aries_cloudagent/protocols/endorse_transaction/v1_0/manager.py", line 268, in create_endorse_response ledger.txn_endorse(transaction_json, endorse_did=endorser_did_info) File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/asyncio/futures.py", line 327, in iter yield self # This tells Task to wait for completion. File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup future.result() File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/asyncio/futures.py", line 243, in result raise self._exception File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/asyncio/tasks.py", line 180, in _step result = coro.send(None) File "/home/indy/aries_cloudagent/ledger/indy.py", line 438, in txn_endorse return await self._endorse(request_json, endorse_did=endorse_did) File "/home/indy/aries_cloudagent/ledger/indy.py", line 337, in endorse wallet.opened.handle, public_info.did, request_json File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/site-packages/indy/ledger.py", line 204, in multi_sign_request c_request_json = c_char_p(request_json.encode('utf-8')) AttributeError: 'dict' object has no attribute 'encode' 2022-09-30 10:26:53,165 aiohttp.access INFO 10.7.54.122 [30/Sep/2022:10:26:53 +0000] "POST /transactions/bcd8f115-59ee-46da-975e-a4237d940e4d/endorse HTTP/1.1" 500 244 "-"
So far we have fixed the problem adding a check on the endorser acapy
at aries_cloudagent/protocols/endorse_transaction/v1_0 async def create_endorse_response ... if isinstance(transaction_json, dict): transaction_json = json.dumps(transaction_json) async with ledger: endorsed_msg = await shield( ledger.txn_endorse(transaction_json, endorse_did=endorser_did_info) ) ...
verifying if the message is a dict or a string.
Obviously doing a dump in case it was a string.
But we don't know if there can be other impacts.