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

Config Schema: Report configuration errors as warnings #8101

Merged
merged 1 commit into from Aug 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 24 additions & 16 deletions lib/classes/ConfigSchemaHandler/index.js
Expand Up @@ -7,6 +7,7 @@ const normalizeAjvErrors = require('./normalizeAjvErrors');

const FUNCTION_NAME_PATTERN = '^[a-zA-Z0-9-_]+$';
const ERROR_PREFIX = 'Configuration error';
const WARNING_PREFIX = 'Configuration warning';

const normalizeSchemaObject = (object, instanceSchema) => {
for (const [key, value] of _.entries(object)) {
Expand Down Expand Up @@ -43,27 +44,29 @@ class ConfigSchemaHandler {
if (!this.schema.properties.provider.properties.name) {
if (this.serverless.service.configValidationMode !== 'off') {
this.serverless.cli.log(
`Configuration error: Unrecognized provider '${this.serverless.service.provider.name}'`,
`${WARNING_PREFIX}: Unrecognized provider '${this.serverless.service.provider.name}'`,
'Serverless',
{ color: 'red' }
{ color: 'orangered' }
);
this.serverless.cli.log(' ');
this.serverless.cli.log(
"You're relying on provider plugin which doesn't " +
'provide a validation schema for its config.',
'Serverless',
{ color: 'grey' }
{ color: 'orange' }
);
this.serverless.cli.log(
'Please report the issue at its bug tracker linking: ' +
'https://www.serverless.com/framework/docs/providers/aws/guide/plugins#extending-validation-schema',
'Serverless',
{ color: 'grey' }
{ color: 'orange' }
);
this.serverless.cli.log(
'You may turn off this message with `configValidationMode: off` setting',
'You may turn off this message with "configValidationMode: off" setting',
'Serverless',
{ color: 'grey' }
{ color: 'orange' }
);
this.serverless.cli.log(' ');
}

this.relaxProviderSchema();
Expand Down Expand Up @@ -95,40 +98,45 @@ class ConfigSchemaHandler {
throw new this.serverless.classes.Error(errorMessage);
} else {
if (messages.length === 1) {
this.serverless.cli.log(`${ERROR_PREFIX} ${messages[0]}`, 'Serverless', { color: 'red' });
this.serverless.cli.log(`${WARNING_PREFIX} ${messages[0]}`, 'Serverless', {
color: 'orangered',
});
} else {
this.serverless.cli.log(`${ERROR_PREFIX}:`, 'Serverless', { color: 'red' });
this.serverless.cli.log(`${WARNING_PREFIX}:`, 'Serverless', {
color: 'orangered',
});
for (const message of messages) {
this.serverless.cli.log(`- ${message}`, 'Serverless', { color: 'red' });
this.serverless.cli.log(` ${message}`, 'Serverless', { color: 'orangered' });
}
}
this.serverless.cli.log(' ');
this.serverless.cli.log(
'If you prefer to not continue when error in configuration is approached, ensure ' +
'`configValidationMode: error` in your config',
'If you prefer to not continue ensure "configValidationMode: error" in your config',
'Serverless',
{ color: 'grey' }
{ color: 'orange' }
);
this.serverless.cli.log(
'If errors are influenced by an external plugin, enquiry at plugin repository so ' +
'schema extensions are added ' +
'(https://www.serverless.com/framework/docs/providers/aws/guide/plugins#extending-validation-schema)',
'Serverless',
{ color: 'grey' }
{ color: 'orange' }
);
this.serverless.cli.log(
'If errors seem invalid, please report at ' +
'https://github.com/serverless/serverless/issues/new?template=bug_report.md',
'Serverless',
{
color: 'grey',
color: 'orange',
}
);
this.serverless.cli.log(
'If you find this functionality problematic, you may turn it off with ' +
'`configValidationMode: off` setting',
'"configValidationMode: off" setting',
'Serverless',
{ color: 'grey' }
{ color: 'orange' }
);
this.serverless.cli.log(' ');
}
}
}
Expand Down