question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DX: Helpful output when serverless.yml is malformed

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
softpropscommented, Nov 20, 2018

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

1reaction
horike37commented, Aug 2, 2017

I think that’s a great idea too. I misunderstood that custom section is for only framework users.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DX: Improve handler validation in serverless.yml #3758 - GitHub
When parsing the serverless.yml file or when packaging the function there could be some basic validation on the handler.
Read more >
Policy malformed when deploying serverless application
Issue seems to be IAM related and isn't a perissions issue so much as AWS says it's a malformed policy. I've included the...
Read more >
Warnings for ignored/malformed objects in serverless.yml
A couple of times, I've gotten snagged by a misspelling or incorrect capitalization of an identifier in a serverless.yml file.
Read more >
AWS Lambda Guide - Serverless.yml Reference
Here is a list of all available properties in serverless.yml when the provider is set to aws . ... 'warn' (logged to the...
Read more >
Serverless Offline - Serverless Framework: Plugins
Serverless Offline. This Serverless plugin emulates AWS λ and API Gateway on your local machine to speed up your development cycles.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found