Plugin throws `Cannot read property 'split' of undefined` when using files references
When splitting config into different files and referencing them through the following pattern —see below— plugin throws Cannot read property 'split' of undefined.
...
resources:
- ${file(resources/cognito-user-pool.yml)}
Full stacktrace:
TypeError: Cannot read property 'split' of undefined
at _.values.map.map.h (/Users/glenn/Dev/Freelancing/Haloha/haloha-api/node_modules/serverless-plugin-typescript/src/typescript.ts:53:31)
at Array.map (<anonymous>)
at Object.extractFileNames (/Users/glenn/Dev/Freelancing/Haloha/haloha-api/node_modules/serverless-plugin-typescript/src/typescript.ts:52:6)
at TypeScriptPlugin.get rootFileNames [as rootFileNames] (/Users/glenn/Dev/Freelancing/Haloha/haloha-api/node_modules/serverless-plugin-typescript/src/index.ts:71:23)
at TypeScriptPlugin.<anonymous> (/Users/glenn/Dev/Freelancing/Haloha/haloha-api/node_modules/serverless-plugin-typescript/src/index.ts:132:51)
at Generator.next (<anonymous>)
at /Users/glenn/Dev/Freelancing/Haloha/haloha-api/node_modules/serverless-plugin-typescript/dist/src/index.js:7:71
at new Promise (<anonymous>)
at __awaiter (/Users/glenn/Dev/Freelancing/Haloha/haloha-api/node_modules/serverless-plugin-typescript/dist/src/index.js:3:12)
at TypeScriptPlugin.compileTs (/Users/glenn/Dev/Freelancing/Haloha/haloha-api/node_modules/serverless-plugin-typescript/dist/src/index.js:103:16)
at BbPromise.reduce (/Users/glenn/.nvm/versions/node/v10.8.0/lib/node_modules/serverless/lib/classes/PluginManager.js:390:55)
From previous event:
at PluginManager.invoke (/Users/glenn/.nvm/versions/node/v10.8.0/lib/node_modules/serverless/lib/classes/PluginManager.js:390:22)
at PluginManager.spawn (/Users/glenn/.nvm/versions/node/v10.8.0/lib/node_modules/serverless/lib/classes/PluginManager.js:408:17)
at Deploy.BbPromise.bind.then.then (/Users/glenn/.nvm/versions/node/v10.8.0/lib/node_modules/serverless/lib/plugins/deploy/deploy.js:123:50)
From previous event:
at Object.before:deploy:deploy [as hook] (/Users/glenn/.nvm/versions/node/v10.8.0/lib/node_modules/serverless/lib/plugins/deploy/deploy.js:113:10)
at BbPromise.reduce (/Users/glenn/.nvm/versions/node/v10.8.0/lib/node_modules/serverless/lib/classes/PluginManager.js:390:55)
From previous event:
at PluginManager.invoke (/Users/glenn/.nvm/versions/node/v10.8.0/lib/node_modules/serverless/lib/classes/PluginManager.js:390:22)
at PluginManager.run (/Users/glenn/.nvm/versions/node/v10.8.0/lib/node_modules/serverless/lib/classes/PluginManager.js:421:17)
at variables.populateService.then.then (/Users/glenn/.nvm/versions/node/v10.8.0/lib/node_modules/serverless/lib/Serverless.js:157:33)
at runCallback (timers.js:693:18)
at tryOnImmediate (timers.js:664:5)
at processImmediate (timers.js:646:5)
at process.topLevelDomainCallback (domain.js:121:23)
From previous event:
at Serverless.run (/Users/glenn/.nvm/versions/node/v10.8.0/lib/node_modules/serverless/lib/Serverless.js:144:8)
at serverless.init.then (/Users/glenn/.nvm/versions/node/v10.8.0/lib/node_modules/serverless/bin/serverless:43:50)
i am getting the same issue when trying to refer to ${self} yml block ex: block i am refferring to:
custom:
authorizerConfig:
name: authorize
type: request
identitySource: method.request.header.Authorization, context.path, context.httpMethod
my reference:
functions:
authorize:
handler: security.authorize
invoke:
handler: service.invoke
events:
- http:
path: entity
method: GET
cors: true
authorizer: ${self:custom.authorizerConfig}
with SLS_DEBUG='*' i get the following stacktrace:
TypeError: Cannot read property 'split' of undefined
at _.values.map.map.h (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless-plugin-typescript/src/typescript.ts:53:31)
at Array.map (<anonymous>)
at Object.extractFileNames (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless-plugin-typescript/src/typescript.ts:52:6)
at TypeScriptPlugin.get rootFileNames [as rootFileNames] (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless-plugin-typescript/src/index.ts:71:23)
at TypeScriptPlugin.<anonymous> (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless-plugin-typescript/src/index.ts:132:51)
at Generator.next (<anonymous>)
at /home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless-plugin-typescript/dist/src/index.js:7:71
at new Promise (<anonymous>)
at __awaiter (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless-plugin-typescript/dist/src/index.js:3:12)
at TypeScriptPlugin.compileTs (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless-plugin-typescript/dist/src/index.js:103:16)
at TypeScriptPlugin.<anonymous> (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless-plugin-typescript/src/index.ts:35:20)
at Generator.next (<anonymous>)
at /home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless-plugin-typescript/dist/src/index.js:7:71
at new Promise (<anonymous>)
at __awaiter (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless-plugin-typescript/dist/src/index.js:3:12)
at Object.before:offline:start [as hook] (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless-plugin-typescript/src/index.ts:34:31)
at BbPromise.reduce (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless/lib/classes/PluginManager.js:391:55)
From previous event:
at PluginManager.invoke (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless/lib/classes/PluginManager.js:391:22)
at PluginManager.run (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless/lib/classes/PluginManager.js:422:17)
at variables.populateService.then.then (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless/lib/Serverless.js:157:33)
at processImmediate (timers.js:632:19)
at process.topLevelDomainCallback (domain.js:120:23)
From previous event:
at Serverless.run (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless/lib/Serverless.js:144:8)
at serverless.init.then (/home/abetaev/documents/dev/nm/universal-cart/node_modules/serverless/bin/serverless:44:28)
@abetaev I'm in the same trouble!
Any ideas of how to fix this?
Had the same issue, but it was just misprint in handler keyword under function name.
I had the same issue, and it was me spelling handler as hander in my yaml file.
I wish the error reporting was clearer on this, since it wasn't related at all to something a dev can recognize and trace