Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

Commit

Permalink
feat: notify maintainers about configuration errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dessant committed Jul 23, 2018
1 parent 7d1ef78 commit f761a6e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"main": "src/index.js",
"scripts": {
"start": "probot run ./src/index.js",
"watch": "nodemon --exec 'npm start'",
"watch": "nodemon --exec 'yarn run start'",
"update": "ncu --upgrade --upgradeAll && yarn",
"push": "git push --follow-tags origin master",
"release": "standard-version && yarn run push"
Expand All @@ -27,6 +27,7 @@
"joi": "^13.4.0",
"probot": "^6.2.0",
"probot-config": "^0.1.0",
"probot-messages": "^0.1.0",
"probot-scheduler": "^1.2.0",
"uuid": "^3.3.0"
},
Expand Down
11 changes: 11 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const uuidV4 = require('uuid/v4');
const firebase = require('firebase-admin');
const createScheduler = require('probot-scheduler');
const getMergedConfig = require('probot-config');
const sendMessage = require('probot-messages');

const App = require('./reaction');
const schema = require('./schema');
Expand Down Expand Up @@ -89,6 +90,16 @@ module.exports = async robot => {
config = value;
} catch (err) {
log.warn({err: new Error(err), repo, file}, 'Invalid config');
if (['YAMLException', 'ValidationError'].includes(err.name)) {
await sendMessage(
robot,
context,
'[{appName}] Configuration error',
'[{appName}]({appUrl}) has encountered a configuration error in ' +
`\`${file}\`.\n\`\`\`\n${err.toString()}\n\`\`\``,
{update: 'The configuration error is still occurring.'}
);
}
}

return config;
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3826,6 +3826,10 @@ probot-config@^0.1.0:
dependencies:
js-yaml "^3.10.0"

probot-messages@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/probot-messages/-/probot-messages-0.1.0.tgz#0a6b279486b2bb40a25e37960f7341ac40e5b0c9"

probot-scheduler@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/probot-scheduler/-/probot-scheduler-1.2.0.tgz#5aba76e589a214934e9db4c39368af592f4dc8b7"
Expand Down

0 comments on commit f761a6e

Please sign in to comment.