botFileSecret : The encrypted value is not a valid format 24.bot-authentication-msgraph
- Type: samples/javascript_nodejs/24.bot-authentication-msgraph/
- Language:nodejs
- Name: 24.bot-authentication-msgraph
Describe the bug
When I execute the bot, it throws Error: The encrypted value is not a valid format, While processing botConfig
Code const BOT_FILE = path.join(__dirname, (process.env.botFilePath || '')); let botConfig; try { // Read bot configuration from .bot file. console.log(BOT_FILE); botConfig = BotConfiguration.loadSync(BOT_FILE, process.env.botFileSecret);
} catch (err) {
console.error(err);
console.error(\nError reading bot file. Please ensure you have valid botFilePath and botFileSecret set for your environment.);
console.error(\n - The botFileSecret is available under appsettings for your Azure Bot Service bot.);
console.error(\n - If you are running this bot locally, consider adding a .env file with botFilePath and botFileSecret.);
console.error(\n - See https://aka.ms/about-bot-file to learn more about .bot file its use and bot configuration.\n\n);
process.exit();
}
Error
node ./index.js
C:\Jenkins\BOT\Office365PeopleSearchBOT.bot
Error: The encrypted value is not a valid format
at decryptString (C:\Jenkins\BOT\node_modules\botframework-config\lib\encrypt.js:54:15)
at EndpointService.decrypt (C:\Jenkins\BOT\node_modules\botframework-config\lib\models\endpointService.js:22:32)
at BotConfiguration.decrypt (C:\Jenkins\BOT\node_modules\botframework-config\lib\botConfiguration.js:178:35)
at Function.internalLoad (C:\Jenkins\BOT\node_modules\botframework-config\lib\botConfiguration.js:155:17)
at Function.loadSync (C:\Jenkins\BOT\node_modules\botframework-config\lib\botConfiguration.js:83:38)
at Object.
Error reading bot file. Please ensure you have valid botFilePath and botFileSecret set for your environment.
-
The botFileSecret is available under appsettings for your Azure Bot Service bot.
-
If you are running this bot locally, consider adding a .env file with botFilePath and botFileSecret.
-
See https://aka.ms/about-bot-file to learn more about .bot file its use and bot configuration.
To Reproduce
index.js file
[bug]
What version of node and NPM are you using?
node : v10.11.0 npm : 6.4.1
@jenkinsns this error occurs when your values in the .bot file don't align with what the bot is looking for.
It's hard to see what value is "off" in the .bot file versus the .env file (i.e. is it the "appPassword"? is it the "padlock"? "botFileSecret"? etc.), so let's start by just generating a new bot file secret
In the terminal, navigate to the folder with your .bot file.
run command: "msbot secret --new" to generate new bot secret
You should see the following output that looks like this with your own secret:

You'll also notice that in your .bot file (in this sample it's called authentication-msgraph.bot) the values for "appPassword" and "padlock" are encrypted now after running the command
copy and paste the new bot secret into your .env file
Specifically copy the value that is right after "Your bot is encrypted with secret:" from the terminal into your .env file

Testing the bot in emulator, open the .bot file, and copy and paste the botFileSecret value as well when prompted
.env file with a secret was mistakenly checked in. rotate the secret and remove the secret
@sgellock Done. @JasonSowers rotated it ASAP (ty)
- Bot appPassword, botFileSecret rotated
- Revision history of
.botfile deleted as well (comment version's existence visible in timeline, but content can't seen)