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

💡 Creating duplicate Credential Definition should return Credential Definition #482

Open
rblaine95 opened this issue Oct 4, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@rblaine95
Copy link
Collaborator

When creating a duplicate Credential Schema, the response is the already existing Credential Schema:

{
  "id": "Hd7nmadkMM7oayBNpkQJzU:2:test_schema:0.3",
  "name": "test_schema",
  "version": "0.3.0",
  "attribute_names": [
    "speed"
  ]
}

However, when creating a duplicate Credential Definition, the response is 400 with a "this definition already exists" message:

{
  "detail": "Cred def for Hd7nmadkMM7oayBNpkQJzU:2:test_schema:0.3.0 asdf already exists"
}

Instead of the already existing Credential Definition:

{
  "id": "NcfXjRU9dvhe291FR5tymb:3:CL:18:assdddffff",
  "tag": "assdddffff",
  "schema_id": "Hd7nmadkMM7oayBNpkQJzU:2:test_schema:0.3.0"
}

In my opinion, for things closely related (like Credential Definitions and Schemas), the response for duplicates should behave the same.
Instead of erroring with a "this already exists" message, it should respond as though the creation was successful and return the already existing definition.

MT Web logs when creating duplicate Credential Definition:
2023-10-04 09:02:39.751 | DEBUG    | app.routes.definitions:create_credential_definition:224 | Publishing credential definition | tag='asdf' schema_id='Hd7nmadkMM7oayBNpkQJzU:2:test_schema:0.3.0' support_revocation=True revocation_registry_size=32767
INFO:     127.0.0.6:57209 - "POST /generic/definitions/credentials HTTP/1.1" 400 Bad Request
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/fastapi/applications.py", line 292, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
  File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 273, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 190, in run_endpoint_function
    return await dependant.call(**values)
  File "/app/routes/definitions.py", line 225, in create_credential_definition
    result = await aries_controller.credential_definition.publish_cred_def(
  File "/usr/local/lib/python3.9/site-packages/aries_cloudcontroller/api/credential_definition.py", line 79, in publish_cred_def
    return await self.__publish_cred_def(
  File "/usr/local/lib/python3.9/site-packages/uplink/clients/io/asyncio_strategy.py", line 32, in execute
    return await executable.execute()
  File "/usr/local/lib/python3.9/site-packages/uplink/clients/io/asyncio_strategy.py", line 19, in invoke
    response = await callback.on_failure(type(error), error, tb)
  File "/usr/local/lib/python3.9/site-packages/uplink/clients/io/asyncio_strategy.py", line 19, in invoke
    response = await callback.on_failure(type(error), error, tb)
  File "/usr/local/lib/python3.9/site-packages/uplink/clients/io/asyncio_strategy.py", line 19, in invoke
    response = await callback.on_failure(type(error), error, tb)
  File "/usr/local/lib/python3.9/site-packages/uplink/clients/io/execution.py", line 108, in on_failure
    return self._io.fail(exc_type, exc_val, exc_tb)
  File "/usr/local/lib/python3.9/site-packages/uplink/clients/io/execution.py", line 128, in fail
    return self._io.fail(exc_type, exc_val, exc_tb)
  File "/usr/local/lib/python3.9/site-packages/uplink/clients/io/interfaces.py", line 300, in fail
    compat.reraise(exc_type, exc_val, exc_tb)
  File "/usr/local/lib/python3.9/site-packages/six.py", line 719, in reraise
    raise value
  File "/usr/local/lib/python3.9/site-packages/uplink/clients/io/asyncio_strategy.py", line 16, in invoke
    response = await func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/uplink/builder.py", line 47, in wrapper
    return func(self._consumer, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/uplink/hooks.py", line 110, in handle_exception
    compat.reraise(exc_type, exc_val, exc_tb)
  File "/usr/local/lib/python3.9/site-packages/six.py", line 719, in reraise
    raise value
  File "/usr/local/lib/python3.9/site-packages/uplink/clients/io/asyncio_strategy.py", line 16, in invoke
    response = await func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/uplink/builder.py", line 47, in wrapper
    return func(self._consumer, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/uplink/hooks.py", line 110, in handle_exception
    compat.reraise(exc_type, exc_val, exc_tb)
  File "/usr/local/lib/python3.9/site-packages/six.py", line 719, in reraise
    raise value
  File "/usr/local/lib/python3.9/site-packages/uplink/clients/io/asyncio_strategy.py", line 16, in invoke
    response = await func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/uplink/clients/aiohttp_.py", line 133, in send
    response = await session.request(method, url, **extras)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 643, in _request
    resp.raise_for_status()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1005, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Cred def for Hd7nmadkMM7oayBNpkQJzU:2:test_schema:0.3.0 asdf already exists', url=URL('http://governance-multitenant-agent:4021/credential-definitions')
@rblaine95 rblaine95 added the enhancement New feature or request label Oct 4, 2023
@ff137 ff137 changed the title Creating duplicate Credential Definition should return Credential Definition 💡 Creating duplicate Credential Definition should return Credential Definition Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant