Repository navigation
Fixed #4188 - Package generating incorrect package artifact path in serverless-state.json - #5297
Conversation
…erverless-state.json
|
@fruffin Why this PR is not moving forward? |
|
I just haven't got around to adding the extra tests and remove the coverage warnings yet. I'll try to look into it this week |
|
Waiting for this PR because the issue is happening with me as well. |
dschep
left a comment
There was a problem hiding this comment.
Yup.. looks pretty good. I would want a test covering this tho. I took a quick stab at adding test coverage myself, but didn't get it working in the short time I'm allotting to each issue/pr I review.
dschep
left a comment
There was a problem hiding this comment.
Furthermore.. in a project without artifact defined I get this error:
$ SLS_DEBUG=t STAGE=test sls deploy
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: WARNING: Missing "tenant" and "app" properties in serverless.yml. Without these properties, you can not publish the service to the Serverless Platform.
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Invoke aws:package:finalize
Type Error ---------------------------------------------
Cannot read property 'substr' of undefined
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Stack Trace --------------------------------------------
TypeError: Cannot read property 'substr' of undefined
at _.forEach.func (/Users/dschep/code/sls/serverless/lib/plugins/aws/package/lib/saveServiceState.js:34:29)
at /Users/dschep/code/sls/serverless/node_modules/lodash/lodash.js:4911:15
at baseForOwn (/Users/dschep/code/sls/serverless/node_modules/lodash/lodash.js:2996:24)
at /Users/dschep/code/sls/serverless/node_modules/lodash/lodash.js:4880:18
at Function.forEach (/Users/dschep/code/sls/serverless/node_modules/lodash/lodash.js:9344:14)
at AwsPackage.saveServiceState (/Users/dschep/code/sls/serverless/lib/plugins/aws/package/lib/saveServiceState.js:30:7)
From previous event:
at Object.aws:package:finalize:saveServiceState [as hook] (/Users/dschep/code/sls/serverless/lib/plugins/aws/package/index.js:81:10)
at BbPromise.reduce (/Users/dschep/code/sls/serverless/lib/classes/PluginManager.js:390:55)
From previous event:
at PluginManager.invoke (/Users/dschep/code/sls/serverless/lib/classes/PluginManager.js:390:22)
at PluginManager.spawn (/Users/dschep/code/sls/serverless/lib/classes/PluginManager.js:408:17)
at AwsPackage.BbPromise.bind.then (/Users/dschep/code/sls/serverless/lib/plugins/aws/package/index.js:69:51)
From previous event:
at Object.package:finalize [as hook] (/Users/dschep/code/sls/serverless/lib/plugins/aws/package/index.js:69:10)
at BbPromise.reduce (/Users/dschep/code/sls/serverless/lib/classes/PluginManager.js:390:55)
From previous event:
at PluginManager.invoke (/Users/dschep/code/sls/serverless/lib/classes/PluginManager.js:390:22)
at PluginManager.spawn (/Users/dschep/code/sls/serverless/lib/classes/PluginManager.js:408:17)
at Deploy.BbPromise.bind.then.then (/Users/dschep/code/sls/serverless/lib/plugins/deploy/deploy.js:123:50)
From previous event:
at Object.before:deploy:deploy [as hook] (/Users/dschep/code/sls/serverless/lib/plugins/deploy/deploy.js:113:10)
at BbPromise.reduce (/Users/dschep/code/sls/serverless/lib/classes/PluginManager.js:390:55)
From previous event:
at PluginManager.invoke (/Users/dschep/code/sls/serverless/lib/classes/PluginManager.js:390:22)
at PluginManager.run (/Users/dschep/code/sls/serverless/lib/classes/PluginManager.js:421:17)
at variables.populateService.then.then (/Users/dschep/code/sls/serverless/lib/Serverless.js:157:33)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
at process.topLevelDomainCallback (domain.js:121:23)
From previous event:
at Serverless.run (/Users/dschep/code/sls/serverless/lib/Serverless.js:144:8)
at serverless.init.then (/Users/dschep/code/sls/serverless/bin/serverless:43:50)
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information -----------------------------
OS: darwin
Node Version: 10.13.0
Serverless Version: 1.31.0
|
I had the same issue see #3525 (comment) for a workaround |
|
Any progress on this PR? |
There was a problem hiding this comment.
Thanks for working on this @fruffin 👍
I just pulled this today and tested it. Added some minor refactorings and a unit test.
Here's the config I've used to test this:
service:
name: test
provider:
name: aws
stage: dev
runtime: nodejs8.10
package:
path: ../dist
functions:
hello:
handler: handler.hello
package:
artifact: ../artifacts/hello.zip
world:
handler: handler.worldLooks like it's working fine.
@warapitiya @ahmed-abdulmoniem @Idanatcox can you test this as well so that we can merge this soon? Thanks!
pmuens
left a comment
There was a problem hiding this comment.
Just tested this again today and couldn't find any issues.
Merging ![]()
What did you implement:
Closes #4188 - Package generating incorrect package artifact path in serverless-state.json
How did you implement it:
Because artifacts are generated in the
.serverlessdirectory first, even if a package path was provided, the reference to the artefact zip file was incorrectly pointing at the.serverlessdirectory.This only needs to be changed at the time the service state is saved, so I have added a few lines to the
saveServiceState.jsfile of the AWS package plugin to fix the paths in the service configuration before saving.How can we verify it:
serverless.ymlfile, specify a package path like so:sls packagecommandserverless-state.jsonfile in thedistdirectory references thedistdirectory for the package path of each functionTodos:
Is this ready for review?: YES
Is it a breaking change?: NO