-
Notifications
You must be signed in to change notification settings - Fork 238
Open
Description
When sending or recieving a message which is compliant with Aries RFC 0509: Action Menu Protocol which contains a valid params dictionary:
Recieved Message
INFO: Received message with type 'https://didcomm.org/action-menu/1.0/perform', recipient key /**/and sender key /**/{
"@type": "https://didcomm.org/action-menu/1.0/perform",
"@id": "/**//",
"name": "echo",
"params": {
"message-text": "asd"
},
"~thread": {
"thid": "85e0a4a3-c4c8-4832-81da-79fd7820fc21"
}
}
Error
ERROR: Error validating message undefined {
"errors": {
"name": "ClassValidationError",
"message": "PerformMessage: Failed to validate class.
An instance of PerformMessage has failed the validation:
- property params has failed the following constraints: each value in params must be a string",
"stack": "ClassValidationError: PerformMessage: Failed to validate class.
An instance of PerformMessage has failed the validation:
- property params has failed the following constraints: each value in params must be a string
at Function.validateSync (.../node_modules/@credo-ts/core/src/utils/MessageValidator.ts:19:13)
at Function.fromJSON (.../node_modules/@credo-ts/core/src/utils/JsonTransformer.ts:35:22)
at MessageReceiver.transformMessage (.../node_modules/@credo-ts/core/src/agent/MessageReceiver.ts:255:44)
at MessageReceiver.transformAndValidate (.../node_modules/@credo-ts/core/src/agent/MessageReceiver.ts:212:28)
at MessageReceiver.receiveEncryptedMessage (.../node_modules/@credo-ts/core/src/agent/MessageReceiver.ts:133:32)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at MessageReceiver.receiveMessage (.../node_modules/@credo-ts/core/src/agent/MessageReceiver.ts:96:9)
at <anonymous> (...node_modules/@credo-ts/node/src/transport/HttpInboundTransport.ts:55:9)",
"validationErrors": [
{
"target": {
"@type": "https://didcomm.org/action-menu/1.0/perform",
"@id": "/**/",
"name": "echo",
"params": {
"message-text": "asd"
},
"~thread": {
"thid": "85e0a4a3-c4c8-4832-81da-79fd7820fc21"
}
},
"value": {
"message-text": "asd"
},
"property": "params",
"children": [],
"constraints": {
"isString": "each value in params must be a string"
}
}
]
},
"message": "{\"@type\":\"https://didcomm.org/action-menu/1.0/perform\",\"@id\":\"/**/\",\"name\":\"echo\",\"params\":{\"message-text\":\"asd\"},\"~thread\":{\"thid\":\"85e0a4a3-c4c8-4832-81da-79fd7820fc21\"}}"
}
The same doesn't happen with an empty params field.
This probably originates from the validation in packages/action-menu/src/messages/PerformMessage.ts
export class PerformMessage extends AgentMessage {
/* ... */
@IsString({ each: true })
@IsOptional()
public params?: Record<string, string>
}I suspect that because Record<string,string> is not a class, only a simple object, the validator doesn't work as expected, or that the each validator option only works with arrays not records.
I think a solution would fall along the lines of this issue.
PS: This issue may become irrelevant if class-validator is replaced by zod #1777
GJanos
Metadata
Metadata
Assignees
Labels
No labels