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 package does 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 custom is the only name allowed for user-defined top level properties, I would expect a warning or error at the serverless package step 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.
  • 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 package prints 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 custom naming 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)

Most upvoted comments

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 custom section is for only framework users.

Talking about third party plugins is actually the one explicit call out that custom gets in the docs, I think.

https://serverless.com/framework/docs/providers/aws/guide/plugins/

Thank you for letting me know this. Ohh, I didn’t know it 😱 However, I have already set the property on the top-level. If I change it, would be BREAKING… 😥

@horike37 🤔 yes, I think the docs might be lacking a callout to put 3rd party plugin config into the custom section. 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.

serverless package prints a warning or error when it detects a top-level property which it’s going to ignore.

There is a case which a new property is added by a plugin. Serverless Step Functions add stepFunctions property 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 😃