serverless: DX: Helpful output when serverless.yml is malformed
This is a Feature Proposal
Description
If a user attempts to put a user-defined top-level property in serverless.yml (other than one called custom), it is silently ignored while packaging and anything referencing that property will fail down the line, potentially not until deployment time.
I think this issue is compounded by the fact that the documentation isn’t entirely clear on the fact that a custom top-level property in the yml file must be called custom.
-
What went wrong?
serverless packagedoes not call out that an improperly named top-level property is defined and will be ignored. Instead, there is only a warning that properties referencing this top-level property have no value. -
What did you expect should have happened?
- If
customis the only name allowed for user-defined top level properties, I would expect a warning or error at theserverless packagestep to alert the user that what they’re trying to do isn’t going to work. - I’d also expect that the documentation would have a sentence explicitly calling out that this naming restriction exists.
- If
-
What was the config you used?
Example serverless.yml exerpt:
service: foo
# This will work
custom: someValue
# This will not
bar: someValue
provider:
...
Feature proposals:
serverless packageprints a warning or error when it detects a top-level property which it’s going to ignore.- Documentation is improved to be more explicit about the
customnaming convention.- If this is desired, I can look at putting in a PR.
Additional Data
- Serverless Framework Version you’re using: 1.18
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (14 by maintainers)
I asked a potentially related question on the forum a while back https://forum.serverless.com/t/formal-specification-of-serverless-yml/6285
Having a json schema representation would enable a feature this gh is asking for as well as tooling for vscode I’m working on
I think that’s a great idea too. I misunderstood that
customsection is for only framework users.Talking about third party plugins is actually the one explicit call out that
customgets in the docs, I think.https://serverless.com/framework/docs/providers/aws/guide/plugins/
@horike37 🤔 yes, I think the docs might be lacking a callout to put 3rd party plugin config into the
customsection. Maybe we should update them…A possible transition for your plugin could be to support both configs for e.g. two minor versions and then update the major and drop the old config.
There is a case which a new property is added by a plugin. Serverless Step Functions add
stepFunctionsproperty to top-level. In the case, we should consider not to print a warning.I took the initiative and tried to resolve this @seanohollaren. Hope its ok 😃