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

Internal server error when creating schema with no attributes #520

Closed
nrempel opened this issue May 21, 2020 · 2 comments
Closed

Internal server error when creating schema with no attributes #520

nrempel opened this issue May 21, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@nrempel
Copy link
Contributor

nrempel commented May 21, 2020

When trying to create a schema, if you send a data structure with no attributes the server will respond with:

500 Internal Server Error

Server got itself in trouble

Server logs:

2020-05-21 17:47:32,561 aries_cloudagent.core.dispatcher ERROR Handler error: schemas_send_schema
Traceback (most recent call last):
  File "/home/indy/aries_cloudagent/issuer/indy.py", line 68, in create_and_store_schema
    origin_did, schema_name, schema_version, json.dumps(attribute_names),
  File "/home/indy/.pyenv/versions/3.6.9/lib/python3.6/site-packages/indy/anoncreds.py", line 71, in issuer_create_schema
    issuer_create_schema.cb)
indy.error.CommonInvalidStructure

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/indy/aries_cloudagent/ledger/indy.py", line 301, in create_and_send_schema
    public_info.did, schema_name, schema_version, attribute_names,
  File "/home/indy/aries_cloudagent/issuer/indy.py", line 68, in create_and_store_schema
    origin_did, schema_name, schema_version, json.dumps(attribute_names),
  File "/home/indy/aries_cloudagent/indy/error.py", line 27, in __exit__
    ) from err_value
aries_cloudagent.issuer.base.IssuerError: Error when creating schema: Error: Invalid structure
  Caused by: Empty list of Schema attributes has been passed


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/indy/aries_cloudagent/messaging/schemas/routes.py", line 110, in schemas_send_schema
    issuer, schema_name, schema_version, attributes
  File "/home/indy/aries_cloudagent/ledger/indy.py", line 304, in create_and_send_schema
    raise LedgerError(err.message) from err
aries_cloudagent.ledger.error.LedgerError: Error when creating schema: Error: Invalid structure
  Caused by: Empty list of Schema attributes has been passed

2020-05-21 17:47:32,563 aiohttp.server ERROR Error handling request
Traceback (most recent call last):
  File "/home/indy/aries_cloudagent/issuer/indy.py", line 68, in create_and_store_schema
    origin_did, schema_name, schema_version, json.dumps(attribute_names),
  File "/home/indy/.pyenv/versions/3.6.9/lib/python3.6/site-packages/indy/anoncreds.py", line 71, in issuer_create_schema
    issuer_create_schema.cb)
indy.error.CommonInvalidStructure

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/indy/aries_cloudagent/ledger/indy.py", line 301, in create_and_send_schema
    public_info.did, schema_name, schema_version, attribute_names,
  File "/home/indy/aries_cloudagent/issuer/indy.py", line 68, in create_and_store_schema
    origin_did, schema_name, schema_version, json.dumps(attribute_names),
  File "/home/indy/aries_cloudagent/indy/error.py", line 27, in __exit__
    ) from err_value
aries_cloudagent.issuer.base.IssuerError: Error when creating schema: Error: Invalid structure
  Caused by: Empty list of Schema attributes has been passed


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/indy/.pyenv/versions/3.6.9/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/home/indy/.pyenv/versions/3.6.9/lib/python3.6/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/home/indy/.pyenv/versions/3.6.9/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/home/indy/.pyenv/versions/3.6.9/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 192, in apply_limiter
    return await task
  File "/home/indy/aries_cloudagent/messaging/schemas/routes.py", line 110, in schemas_send_schema
    issuer, schema_name, schema_version, attributes
  File "/home/indy/aries_cloudagent/ledger/indy.py", line 304, in create_and_send_schema
    raise LedgerError(err.message) from err
aries_cloudagent.ledger.error.LedgerError: Error when creating schema: Error: Invalid structure
  Caused by: Empty list of Schema attributes has been passed

It should instead catch the error and respond with a more helpful message and appropriate HTTP status code.

@sklump
Copy link
Contributor

sklump commented May 26, 2020

I'll take this among an overall error case polishing on messaging/schemas/.

@sklump
Copy link
Contributor

sklump commented May 27, 2020

Included in #527

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants