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

[rest] Error handling and validation #125

Open
berendsliedrecht opened this issue Jun 17, 2022 · 2 comments
Open

[rest] Error handling and validation #125

berendsliedrecht opened this issue Jun 17, 2022 · 2 comments

Comments

@berendsliedrecht
Copy link
Contributor

berendsliedrecht commented Jun 17, 2022

Ive had some issues with the errors that are being returned from the api. For example, I think I forgot a field in the credentials/offer-credential endpoint and this was the response:

[error] Internal Server Error (status code: 500)! Message: {"stack":"TypeError: Cannot read properties of undefined (reading 'startsWith')\n    at Object.replaceLegacyDidSovPrefix (/www/node_modules/@aries-framework/core/build/utils/messageType.js:15:21)\n    at Object.class_transformer_1.Transform.toClassOnly [as transformFn] (/www/node_modules/@aries-framework/core/build/modules/credentials/messages/CredentialPreview.js:86:64)\n    at /www/node_modules/class-transformer/cjs/TransformOperationExecutor.js:358:30\n    at Array.forEach (<anonymous>)\n    at TransformOperationExecutor.applyCustomTransformations (/www/node_modules/class-transformer/cjs/TransformOperationExecutor.js:357:19)\n    at TransformOperationExecutor.transform (/www/node_modules/class-transformer/cjs/TransformOperationExecutor.js:300:47)\n    at TransformOperationExecutor.transform (/www/node_modules/class-transformer/cjs/TransformOperationExecutor.js:299:47)\n    at ClassTransformer.plainToInstance (/www/node_modules/class-transformer/cjs/ClassTransformer.js:27:25)\n    at Object.plainToClass (/www/node_modules/class-transformer/cjs/index.js:34:29)\n    at ActionParameterHandler.transformValue (/www/node_modules/routing-controllers/cjs/ActionParameterHandler.js:189:41)","message":"Cannot read properties of undefined (reading 'startsWith')"}

I believe if we only send the message field, Cannot read properties of undefined (reading 'startsWith') back it will already be a lot better. But this error also goes into my second point, startsWith is being called on undefined, so apparently I forgot a value in my call but I have no idea which one.

Some stricter validation with better error messages would be insanely benificial.

@berendsliedrecht
Copy link
Contributor Author

My request body for this error (in Rust debug prints was this):

[trace] Some(
    Object({
        "attachments": String(
            "string",
        ),
        "comment": String(
            "string",
        ),
        "connectionId": String(
            "foo",
        ),
        "credentialDefinitionId": String(
            "bar",
        ),
        "preview": Object({
            "attributes": Array([
                String(
                    "string",
                ),
            ]),
            "type": String(
                "https://didcomm.org/issue-credential/1.0/credential-preview",
            ),
        }),
    }),
)

@TimoGlastra
Copy link
Contributor

Will this be fixed by #148?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants