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.

Should empty array trigger warning?

See original GitHub issue

This is a Question

Description

https://github.com/serverless/serverless/blob/ddb99af627276d39858433f88b54608038e7b461/lib/classes/Variables.js#L343

typeof [] === ‘object’ so this causes empty arrays to trigger a warning. Intended? Or worth a check for !Array.isArray)?

Additional Data

  • Serverless Framework Version you’re using: latest (Master)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
fivepapertigerscommented, May 1, 2018

I’m running into the same problem as @antogyn, specifically for API keys. More generally, an empty object or an empty array is often intentional, but we have our CI setup to fail on serverless warnings, because null or undefined values usually are not.

1reaction
antogyncommented, Apr 26, 2018

I use empty arrays sometimes in my config (e.g. for api keys on a particular environment) and I couldn’t find a workaround for this warning.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to trigger a break when an Array is empty? - Stack Overflow
One idea would be to add a didSet{} block to the property that holds the array, adding a log statement within - break...
Read more >
This is why you should pass an empty array into useEffect
Empty array means no dependencies can trigger the supplied function to run again, therefor it will only run once. No argument at all...
Read more >
empty - Manual - PHP
Determine whether a variable is considered to be empty. A variable is considered empty if it does not exist or if its value...
Read more >
Empty arrays and collections should be returned instead of null
Returning null instead of an actual array, collection or map forces callers of the method to explicitly test for nullity, making them more...
Read more >
Dependency array in useEffect hook | by Shreejit Rajbanshi
An empty array simply means that there are no dependencies that will trigger the callback within it. Our code inside the callback will...
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