question

Lucas Mendes avatar image
Lucas Mendes asked

Skill validation tests does not work properly

Hi there,

I'm developing an Alexa Custom Skill using NodeJS, and I'm using `ask-sdk-core` and `ask-sdk-express-adapter` to develop the skill handlers, but when I'm running the Validation tests on Alexa Developer Console, I'm getting the following error:


The skill is rejecting the request when executed with additional properties in the JSON request. 
When we invoke the skill with additional parameters, the skill is rejecting it when we expect this to be accepted. Future versions of the Alexa Skills Kit may add new properties to the JSON request and response formats, while maintaining backward compatibility for the existing properties. Your code must be resilient to these types of changes. For example, your code for de-serializing a JSON request must not break when it encounters a new, unknown property. Please ensure that your code can handle new attributes and does not break when it encounters new properties in the JSON request. Documentation Help: Request and response JSON reference: Click here


When I look at my server logs, I see the following errors:

REQUEST => {
    "version": "1.0",
    "session": {
        "new": true,
        "sessionId": "SessionId.fdaac61a-0055-4dfb-98e1-dbe689d9053f",
        "application": {
            "applicationId": "amzn1.ask.skill.f6f95246-6254-46d0-a04e-177085d0ebda"
        },
        "user": {
            "userId": "amzn1.ask.account.AFPD7X2V7URSRH2TRODZY4PP6HUWI5WKKYO7ATP4IJTLSZQVPBLIYQFEC6O25R6R7CSLGF6GG4Y5NXTNYR5T3GAGM7Y7KF76PFMP3656C4IBG2MMQCAYYN2YLEEM7RQEOKMISJ3RGSMOPV67UTECXZD5UGW76KSCFFPFCVFO7WLIWBKRR3EQRJGQND2R4NYWM7OQQQQ34OXG4KA"
        }
    },
    "context": {
        "AudioPlayer": {
            "offsetInMilliseconds": 0,
            "token": null,
            "playerActivity": "IDLE"
        },
        "System": {
            "application": {
                "applicationId": "amzn1.ask.skill.f6f95246-6254-46d0-a04e-177085d0ebda"
            },
            "user": {
                "userId": "amzn1.ask.account.AFPD7X2V7URSRH2TRODZY4PP6HUWI5WKKYO7ATP4IJTLSZQVPBLIYQFEC6O25R6R7CSLGF6GG4Y5NXTNYR5T3GAGM7Y7KF76PFMP3656C4IBG2MMQCAYYN2YLEEM7RQEOKMISJ3RGSMOPV67UTECXZD5UGW76KSCFFPFCVFO7WLIWBKRR3EQRJGQND2R4NYWM7OQQQQ34OXG4KA"
            },
            "device": {
                "deviceId": "amzn1.ask.device.AFGBQEZEUVWSHSSNXXMG4DPG6RIJNE37G4FA5H7NA4HUK5TVKNXQMA5WFFTUMJEFZ2A7ZQ2TKWUK3UEIVQI5ETNLW57DEGSG3BA35UP6R6XIYRP5FJMT2CZ5T3SUWOITORMBHFVMW23YZLF256SDRI43Z5DGTV7EV2W5F3N6LEHERT5KAQY3C",
                "supportedInterfaces": {
                    "AudioPlayer": {}
                }
            },
            "apiEndpoint": "https://api.amazonalexa.com",
            "apiAccessToken": "ACCESS_TOKEN"
        }
    },
    "request": {
        "type": "LaunchRequest",
        "requestId": "amzn1.echo-api.request.da36c53b-73e1-4499-a93d-62847f789e2a",
        "timestamp": "2022-07-23T20:22:41Z",
        "locale": "pt-BR",
        "body": null,
        "payload": null,
        "shouldLinkResultBeReturned": false,
        "_utteranceId": null
    },
    "certificationParam1": "hello",
    "certificationParam2": "10000"
}

RESPONSE => AskSdk.Request verification failed Error, request body and signature does not match
REQUEST => {
    "version": "1.0",
    "session": {
        "new": true,
        "sessionId": "SessionId.fdaac61a-0055-4dfb-98e1-dbe689d9053f",
        "application": {
            "applicationId": "amzn1.ask.skill.f6f95246-6254-46d0-a04e-177085d0ebda"
        },
        "attributes": {},
        "user": {
            "userId": "amzn1.echo-sdk-account.AHM3UO2HNVE5AD5ONKQM54FZZSNCR5YXMY2HNEQDDS5MVREKRKQT6"
        }
    },
    "request": {
        "type": "LaunchRequest",
        "requestId": "amzn1.echo-api.request.8af47e90-7469-42a1-9d1f-5f787aaaa5be",
        "locale": "pt-BR",
        "timestamp": "2022-07-23T20:22:43Z"
    },
    "context": {
        "System": {
            "application": {
                "applicationId": "amzn1.ask.skill.f6f95246-6254-46d0-a04e-177085d0ebda"
            },
            "user": {
                "userId": "amzn1.echo-sdk-account.AHM3UO2HNVE5AD5ONKQM54FZZSNCR5YXMY2HNEQDDS5MVREKRKQT6"
            },
            "device": {
                "deviceId": "amzn1.ask.device.AHDSWM35QQEQLZKQJZAIVVSTLTYZO7YSCS5VTYAKY6PJLJUMVH63QDX4XHUBWCLXDVQN44AC4EFAI24KUXNBLJXGWXPT67BXZZI3E6NRU5TSGYIQS5R5FKJRRT5FO7HEWTTFJ2ZZ4QYHA5YQL4CPYSZVXJSQ",
                "supportedInterfaces": {
                    "AudioPlayer": {}
                }
            },
            "apiEndpoint": "https://api.amazonalexa.com",
            "apiAccessToken": "ACCESS_TOKEN"
        },
        "AudioPlayer": {
            "offsetInMilliseconds": 0,
            "playerActivity": "IDLE"
        }
    }
}
RESPONSE => AskSdk.Request verification failed Error, Missing Signature for the skill request
REQUEST => {
    "version": "1.0",
    "session": {
        "new": true,
        "sessionId": "SessionId.fdaac61a-0055-4dfb-98e1-dbe689d9053f",
        "application": {
            "applicationId": "amzn1.ask.skill.f6f95246-6254-46d0-a04e-177085d0ebda"
        },
        "attributes": {},
        "user": {
            "userId": "amzn1.echo-sdk-account.AHM3UO2HNVE5AD5ONKQM54FZZSNCR5YXMY2HNEQDDS5MVREKRKQT6"
        }
    },
    "request": {
        "type": "LaunchRequest",
        "requestId": "amzn1.echo-api.request.8af47e90-7469-42a1-9d1f-5f787aaaa5be",
        "locale": "pt-BR",
        "timestamp": "2022-07-23T20:22:43Z"
    },
    "context": {
        "System": {
            "application": {
                "applicationId": "amzn1.ask.skill.f6f95246-6254-46d0-a04e-177085d0ebda"
            },
            "user": {
                "userId": "amzn1.echo-sdk-account.AHM3UO2HNVE5AD5ONKQM54FZZSNCR5YXMY2HNEQDDS5MVREKRKQT6"
            },
            "device": {
                "deviceId": "amzn1.ask.device.AHDSWM35QQEQLZKQJZAIVVSTLTYZO7YSCS5VTYAKY6PJLJUMVH63QDX4XHUBWCLXDVQN44AC4EFAI24KUXNBLJXGWXPT67BXZZI3E6NRU5TSGYIQS5R5FKJRRT5FO7HEWTTFJ2ZZ4QYHA5YQL4CPYSZVXJSQ",
                "supportedInterfaces": {
                    "AudioPlayer": {}
                }
            },
            "apiEndpoint": "https://api.amazonalexa.com",
            "apiAccessToken": "ACCESS_TOKEN"
        },
        "AudioPlayer": {
            "offsetInMilliseconds": 0,
            "playerActivity": "IDLE"
        }
    }
}
RESPONSE => AskSdk.Request verification failed Error, Missing Signature for the skill request
REQUEST => {
    "version": "1.0",
    "session": {
        "new": true,
        "sessionId": "SessionId.fdaac61a-0055-4dfb-98e1-dbe689d9053f",
        "application": {
            "applicationId": "amzn1.ask.skill.f6f95246-6254-46d0-a04e-177085d0ebda"
        },
        "attributes": {},
        "user": {
            "userId": "amzn1.echo-sdk-account.AHM3UO2HNVE5AD5ONKQM54FZZSNCR5YXMY2HNEQDDS5MVREKRKQT6"
        }
    },
    "request": {
        "type": "LaunchRequest",
        "requestId": "amzn1.echo-api.request.8af47e90-7469-42a1-9d1f-5f787aaaa5be",
        "locale": "pt-BR",
        "timestamp": "2022-07-23T20:22:43Z"
    },
    "context": {
        "System": {
            "application": {
                "applicationId": "amzn1.ask.skill.f6f95246-6254-46d0-a04e-177085d0ebda"
            },
            "user": {
                "userId": "amzn1.echo-sdk-account.AHM3UO2HNVE5AD5ONKQM54FZZSNCR5YXMY2HNEQDDS5MVREKRKQT6"
            },
            "device": {
                "deviceId": "amzn1.ask.device.AHDSWM35QQEQLZKQJZAIVVSTLTYZO7YSCS5VTYAKY6PJLJUMVH63QDX4XHUBWCLXDVQN44AC4EFAI24KUXNBLJXGWXPT67BXZZI3E6NRU5TSGYIQS5R5FKJRRT5FO7HEWTTFJ2ZZ4QYHA5YQL4CPYSZVXJSQ",
                "supportedInterfaces": {
                    "AudioPlayer": {}
                }
            },
            "apiEndpoint": "https://api.amazonalexa.com",
            "apiAccessToken": "ACCESS_TOKEN"
        },
        "AudioPlayer": {
            "offsetInMilliseconds": 0,
            "playerActivity": "IDLE"
        }
    }
}
RESPONSE => AskSdk.Request verification failed Error, SignatureCertChainUrl has invalid path: /blah.api/echo-api-cert-3.pem. Expecting the path to start with /echo.api/
REQUEST => {
    "version": "1.0",
    "session": {
        "new": true,
        "sessionId": "SessionId.fdaac61a-0055-4dfb-98e1-dbe689d9053f",
        "application": {
            "applicationId": "amzn1.ask.skill.f6f95246-6254-46d0-a04e-177085d0ebda"
        },
        "attributes": {},
        "user": {
            "userId": "amzn1.echo-sdk-account.AHM3UO2HNVE5AD5ONKQM54FZZSNCR5YXMY2HNEQDDS5MVREKRKQT6"
        }
    },
    "request": {
        "type": "LaunchRequest",
        "requestId": "amzn1.echo-api.request.8af47e90-7469-42a1-9d1f-5f787aaaa5be",
        "locale": "pt-BR",
        "timestamp": "2022-07-23T20:22:43Z"
    },
    "context": {
        "System": {
            "application": {
                "applicationId": "amzn1.ask.skill.f6f95246-6254-46d0-a04e-177085d0ebda"
            },
            "user": {
                "userId": "amzn1.echo-sdk-account.AHM3UO2HNVE5AD5ONKQM54FZZSNCR5YXMY2HNEQDDS5MVREKRKQT6"
            },
            "device": {
                "deviceId": "amzn1.ask.device.AHDSWM35QQEQLZKQJZAIVVSTLTYZO7YSCS5VTYAKY6PJLJUMVH63QDX4XHUBWCLXDVQN44AC4EFAI24KUXNBLJXGWXPT67BXZZI3E6NRU5TSGYIQS5R5FKJRRT5FO7HEWTTFJ2ZZ4QYHA5YQL4CPYSZVXJSQ",
                "supportedInterfaces": {
                    "AudioPlayer": {}
                }
            },
            "apiEndpoint": "https://api.amazonalexa.com",
            "apiAccessToken": "ACCESS_TOKEN"
        },
        "AudioPlayer": {
            "offsetInMilliseconds": 0,
            "playerActivity": "IDLE"
        }
    }
}
RESPONSE => AskSdk.Request verification failed Error, request body and signature does not match


In my code, I only have the following things, I'm not performing any manual validation or request matching, since the ExpressAdapter and the ASK SDK Code should do that for me, right?

const express = require('express');
const morgan = require('morgan');
const logger = require('./logger')();
const dotenv = require('dotenv');
const Alexa = require('ask-sdk-core');
const { ExpressAdapter } = require('ask-sdk-express-adapter');

const ErrorHandler = require('./handlers/errorHandler');
const LaunchRequestHandler = require('./handlers/launchRequestHandler');
const SessionEndedRequestHandler = require('./handlers/sessionEndedRequestHandler');

const DEFAULT_PORT = 3000;

const Application = () => {
  dotenv.config();

  const app = express();
  const port = process.env.PORT ?? DEFAULT_PORT;

  app.use(morgan('combined));

  const skillBuilder = Alexa.SkillBuilders.custom();
  const skill = skillBuilder
    .withSkillId(process.env.ALEXA_SKILL_ID)
    .withApiClient(new Alexa.DefaultApiClient())
    .addErrorHandlers(ErrorHandler(logger))
    .addRequestHandlers(LaunchRequestHandler(logger), SessionEndedRequestHandler(logger))
    .create();

  const adapter = new ExpressAdapter(skill, true, true);

  app.get('/', (req, res) => {
    res.send('PARE!!');
  });

  app.post('/', adapter.getRequestHandlers());

  app.listen(port, () => {
    console.log(`Listening at port: ${port}`);
  });
};

module.exports = Application;

That makes me think that the error presented in the Console does not match the actual problem, because if I send a valid request with any additional property, the application does not breaks and answers correctly, and the real problem here is more about the authorization/authentication rather than the properties.

And there's a twist, if I change the ExpressAdapter's parameters from true to false, all the requests passes with a 200 OK status code, but then I get a new error that says that I'm not validating the requests, so I was think, may this is an inconsistency on the Validation engine from Amazon's side? Because my application is answering accordingly to the specifications and documentations... What can I do?

Thanks in advance!

alexa skills kitalexa skills
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers