Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Variables): Fix when properties are null #8165

Open
wants to merge 1 commit into
base: master
from

Conversation

@MystK
Copy link

@MystK MystK commented Sep 1, 2020

I thought this qualifies for a small and obvious bug, so I did not open an issue.

What is happening is when my file is empty, reducedValue is null and throws an error that the variable could not be found. See error below.

  TypeError: Cannot read property 'XXXXXXXXXXXXXXXXXXXXXXX' of null
      at C:\dev\XXXXX\node_modules\serverless\lib\classes\Variables.js:891:40
      at tryCatcher (C:\dev\XXXXX\node_modules\bluebird\js\release\util.js:16:23)
      at Object.gotValue (C:\dev\XXXXX\node_modules\bluebird\js\release\reduce.js:157:18)
      at Object.gotAccum (C:\dev\XXXXX\node_modules\bluebird\js\release\reduce.js:144:25)
      at Object.tryCatcher (C:\dev\XXXXX\node_modules\bluebird\js\release\util.js:16:23)
      at Promise._settlePromiseFromHandler (C:\dev\XXXXX\node_modules\bluebird\js\release\promise.js:517:31)
      at Promise._settlePromise (C:\dev\XXXXX\node_modules\bluebird\js\release\promise.js:574:18)
      at Promise._settlePromiseCtx (C:\dev\XXXXX\node_modules\bluebird\js\release\promise.js:611:10)
      at _drainQueueStep (C:\dev\XXXXX\node_modules\bluebird\js\release\async.js:142:12)
      at _drainQueue (C:\dev\XXXXX\node_modules\bluebird\js\release\async.js:131:9)
      at Async._drainQueues (C:\dev\XXXXX\node_modules\bluebird\js\release\async.js:147:5)
      at Immediate.Async.drainQueues [as _onImmediate] (C:\dev\XXXXX\node_modules\bluebird\js\release\async.js:17:14)
      at processImmediate (internal/timers.js:456:21)
      at process.topLevelDomainCallback (domain.js:137:15)
@codecov-commenter
Copy link

@codecov-commenter codecov-commenter commented Sep 1, 2020

Codecov Report

Merging #8165 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #8165   +/-   ##
=======================================
  Coverage   88.24%   88.24%           
=======================================
  Files         248      248           
  Lines        9424     9424           
=======================================
  Hits         8316     8316           
  Misses       1108     1108           
Impacted Files Coverage Δ
lib/classes/Variables.js 99.72% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7aad819...e26f449. Read the comment docs.

Copy link
Member

@medikoo medikoo left a comment

Thank you @MystK that's definitely a right call. Please see my suggestion, also do you think you can patch a regression test for this?

@@ -949,7 +949,7 @@ class Variables {
reducedValue = this.appendDeepVariable(reducedValue, subProperty);
} else {
// get mode
if (typeof reducedValue === 'undefined') {
if (typeof reducedValue === 'undefined' || reducedValue === null) {

This comment has been minimized.

@medikoo

medikoo Sep 2, 2020
Member

Let's replace it with equivalent if (reducedValue == null)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.