Configuration validation
The Serverless Framework checks your serverless.yml against a JSON schema before it runs a command, and reports unknown properties, wrong types and values outside the allowed set. The top-level configValidationMode setting decides what happens when the configuration doesn't match the schema: print a warning and continue (the default), stop the command, or report nothing.
To stop every command on an invalid configuration, which is useful in CI, set configValidationMode: error at the top level of serverless.yml:
# serverless.yml
service: my-service
configValidationMode: error
provider:
name: aws
runtime: nodejs24.x
functions:
hello:
handler: handler.hello
configValidationMode values
configValidationMode is a top-level string that applies to the whole service. It has no per-function or per-stage form, and it accepts variables such as ${env:CONFIG_VALIDATION_MODE, 'warn'}.
| Value | What happens when the configuration doesn't match the schema |
|---|---|
warn | Default. The Framework prints an Invalid configuration encountered warning that lists each error, and the command continues. |
error | The command stops with exit code 1 and prints each error (Configuration error ...). Nothing is packaged or deployed. |
off | The Framework prints no schema errors, and the command continues. |
Any other value is itself reported as a schema error (at 'configValidationMode': must be equal to one of the allowed values [error, warn, off]), and the schema validation then behaves as with warn.
When validation runs
- On every command that loads the service's configuration:
deploy,package,print,info,invokeand the others. Theserverless plugincommands skip it, and so do commands that don't load the service, such asserverless login,serverless usage,serverless agent setupandserverless mcp. - After variables are resolved, so the schema sees the final values, not the
${...}references. - Against the schema of the Framework plus the schema each loaded plugin adds. Properties a plugin reads at the top level, in
provideror in a function without describing them in a schema are reported as unrecognized.customaccepts any property, and thePropertiesof a CloudFormation resource underresourcesaren't checked.
To check a configuration without deploying, run serverless print. It runs the same validation and prints the resolved configuration.
serverless print
Validation messages
With configValidationMode: warn (or no setting), errors appear as a warning at the start of the command output, one line per error, with the path of the property:
[!] Invalid configuration encountered
at 'provider': unrecognized property 'timeoutt'
Learn more about configuration validation here: http://slss.io/configuration-validation
With configValidationMode: error, a single error is printed on one line and several errors are listed below the heading:
✖ ServerlessError: Configuration error:
at 'functions.hello.memorySize': must be integer
at 'provider': unrecognized property 'timeoutt'
Learn more about configuration validation here: http://slss.io/configuration-validation
The message forms that occur most often:
unrecognized property '<name>': the property isn't in the schema. Check the spelling against the serverless.yml reference. If a plugin owns the property, the plugin doesn't declare it in a schema.must be integer,must be string,must be object: the value has the wrong type.must be equal to one of the allowed values [...]: the value isn't one of the listed values.
Fix a validation error
- Find the property in the message path (
functions.hello.memorySizeismemorySizeunder thehellofunction). - Compare it with the serverless.yml reference or the page for the feature, and correct the name, type or value.
- Run
serverless printto confirm the warning or error is gone.
If the property belongs to a plugin, ask the plugin's maintainers to declare it; Extending the configuration schema shows plugin authors how. If you're sure the configuration is valid and the Framework's own schema is missing a property, report it in the Serverless Framework issue tracker.
Checks that configValidationMode doesn't control
Some checks run outside the schema validation, so configValidationMode changes only part of what they do:
- Web apps (
webApps) and sandboxes (sandboxes) validate their own settings before packaging and stop the command on an invalid value, in every mode. - AppSync (
appSync) configuration errors follow the mode: they stop the command witherror, print a warning withwarn, and are not reported withoffor with aconfigValidationModevalue outside the allowed set. - An invalid
frameworkVersionrange stops the command witherror, and prints a warning withwarnandoff.
With warn or off, a deploy of an invalid configuration continues, and AWS CloudFormation or the feature that reads the value can still reject it later in the deploy.
Related
- serverless.yml reference: every property the Framework accepts.
- Extending the configuration schema: how plugins declare their properties.
serverless print: print the resolved configuration.