openwallet-foundation / credo-ts

Typescript framework for building decentralized identity and verifiable credential solutions
https://credo.js.org
Apache License 2.0
273 stars 200 forks source link

Unable to Determine Tenant ID for Inbound Message in Connectionless Credential Issuance #1701

Closed Sshovon closed 10 months ago

Sshovon commented 10 months ago

I use a multi-tenancy configuration with the Aries Framework's tenants module, version 0.4.2, for both the issuer and holder agent. On the issuer side, I create a credential offer and an oob invitation with the handshake set to false, including the credential offer message in the invitation. On the holder side, I initiate the connection acceptance using oob.receiveInvitationFromUrl and subsequently accept the credential offer through credentials.acceptOffer. The holder agent receives the credential request upon invoking the receiveInvitationFromUrl function and emits a request-sent event after the execution of credentials.acceptOffer. Notably, the issuer does not emit any events related to the credential state change upon receiving the request from the holder, and an error is observed in the issuer's logger trace.

ERROR: Error processing inbound message: Couldn't determine tenant id for inbound message. Unable to create context {
  "name": "AriesFrameworkError",
  "message": "Couldn't determine tenant id for inbound message. Unable to create context",
  "stack": "AriesFrameworkError: Couldn't determine tenant id for inbound message. Unable to create context\n    at TenantAgentContextProvider.getContextForInboundMessage (/home/agents/node_modules/@aries-framework/tenants/src/context/TenantAgentContextProvider.ts:96:13)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async MessageReceiver.receiveMessage (/home/agents/node_modules/@aries-framework/core/src/agent/MessageReceiver.ts:90:26)\n    at async /home/agents/node_modules/@aries-framework/node/src/transport/HttpInboundTransport.ts:51:9"
}
Sshovon commented 10 months ago
DEBUG: Agent received message
DEBUG: Getting context for inbound message in tenant agent context provider {}
TRACE: Inbound message is a JWE, extracting tenant id from JWE's protected header
TRACE: Found 1 recipient keys in JWE's protected header
ERROR: Couldn't determine tenant id for inbound message. Unable to create context {
  "inboundMessage": {
    "protected": "eyJlbmMiOiJ4Y2hhY2hhMjBwb2x5MTMwNV9pZXRmIiwidHlwIjoiSldNLzEuMCIsImFsZyI6IkF1dGhjcnlwdCIsInJlY2lwaWVudHMiOlt7ImVuY3J5cHRlZF9rZXkiOiJNWXRpb0s3NWRB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pj0vk_iNCnlg8B2TWKm9CMFfvgJCh83OV7yOffrq5Wr4VLrIWKDxsw6brbIuzH_7gtW3LBYrWgeyp7pcy7EbHC3OQ4tb1UbQMvl-ush728tC0QFDELCoMRNaCrUsseXAICtJ_PkpdfcmTH61SLKuKMK40BRmYPPL0MHpugq1nw6Ym2sT4WL1JFg_us-Gss5-_NC9h2qEaJmN02kuMpo4_K9Lp58x7ujfQX9_Uij3whw2P28i0eYv9Cq4mqI0GQCSGPRoHg7ZVsWR0it9KytNg-l6yxn6c7C08bH2uHUgXYYXApfx0n1eqU6SIlQ2QpL7ot3N8JCtOieCCbnJAEFRdlbSQbwn8srAf5Fqz4P8a56kU_i1wJprHhVmDjm0OTYurghg4G9PdhYdHPKsHXqaAc__llalWVtlxECd",
    "iv": "BagvQ8UwSUJjrFmj",
    "tag": "Dll1qL4qeg4AVhbmclL_0A"
  },
  "recipientKeys": [
    "z6MkmVciTJHbWSofUsYAqu9MSB7oQ3xq9NPWVn1dTfGfFru6"
  ]
}
TimoGlastra commented 10 months ago

There should be a log created when the out of band invitation is created with the following structure (ids and keys replaced):

Received routing key created event for tenant ${contextCorrelationId}, registering recipient key ${recipientKey.fingerprint} in base wallet

Could you check if this is logged for key z6MkmVciTJHbWSofUsYAqu9MSB7oQ3xq9NPWVn1dTfGfFru6?

TimoGlastra commented 10 months ago

And could you also check if a RoutingCreatedEvent is emitted (RoutingEventTypes.RoutingCreatedEvent) at the time you create the invitation?

https://github.com/openwallet-foundation/agent-framework-javascript/blob/main/packages/core/src/modules/routing/services/RoutingService.ts#L44-L50

It should emit this, and that's what the tenants module hooks into for registering the mapping of key -> tenantId.

TimoGlastra commented 10 months ago

And finally could you check if this is logged after startup of the agent:

Listening for routing key created events in tenant agent context provider
Sshovon commented 10 months ago

It's resolved. Thanks.

TimoGlastra commented 10 months ago

What was the solution?

Sshovon commented 10 months ago

The issue was occurring possibly due to conflicting packages. I have cleared the yarn cache, removed the node_modules, and reinstalled the dependencies. It worked for the same code.