core: TypeError: Cannot read properties of undefined (reading 'warnIfFlagDeprecated')
Describe the bug
I am running oclif as a dependency of twilio-cli (specifically, twilio-cli-core). When trying to run commands using the twilio command line tool, I get the following error:
/github/home/.twilio-cli/node_modules/@oclif/core/lib/command.js:153
this.warnIfFlagDeprecated(results.flags ?? {});
^
TypeError: Cannot read properties of undefined (reading 'warnIfFlagDeprecated')
at parse (/github/home/.twilio-cli/node_modules/@oclif/core/lib/command.js:153:14)
at async /github/home/.twilio-cli/node_modules/@twilio-labs/plugin-flex/dist/utils/parser.js:113:42
at async FlexPluginsDeploy.init (/github/home/.twilio-cli/node_modules/@twilio-labs/plugin-flex/dist/commands/flex/plugins/deploy.js:65:[24](https://github.com/transferwise/plugin-twilio-flex/actions/runs/3272804474/jobs/5384283979#step:10:25))
at async FlexPluginsDeploy._run (/github/home/.twilio-cli/node_modules/@oclif/core/lib/command.js:79:13)
at async Config.runCommand (/usr/local/lib/node_modules/twilio-cli/node_modules/@oclif/config/lib/config.js:173:24)
at async Main.run (/usr/local/lib/node_modules/twilio-cli/node_modules/@oclif/command/lib/main.js:[27](https://github.com/transferwise/plugin-twilio-flex/actions/runs/3272804474/jobs/5384283979#step:10:28):9)
at async Main._run (/usr/local/lib/node_modules/twilio-cli/node_modules/@oclif/command/lib/command.js:43:20)
The exact context of the exception is this:
warnIfFlagDeprecated(flags) {
for (const flag of Object.keys(flags)) {
const deprecated = this.ctor.flags[flag]?.deprecated;
if (deprecated) {
this.warn((0, util_2.formatFlagDeprecationWarning)(flag, deprecated));
}
}
}
warnIfCommandDeprecated() {
if (this.ctor.state === 'deprecated') {
const cmdName = (0, index_1.toConfiguredId)(this.ctor.id, this.config);
this.warn((0, util_2.formatCommandDeprecationWarning)(cmdName, this.ctor.deprecationOptions));
}
}
async parse(options, argv = this.argv) {
if (!options)
options = this.constructor;
const opts = { context: this, ...options };
// the spread operator doesn't work with getters so we have to manually add it here
opts.flags = options?.flags;
opts.args = options?.args;
const results = await Parser.parse(argv, opts);
this.warnIfFlagDeprecated(results.flags ?? {}); // <-- ERROR
return results;
}
This looks like it could have been introduced by https://github.com/oclif/core/pull/527 (1.19.0) Our job was still passing 21 hours ago; the PR linked was merged 16 hours ago; our first job today was 3 hours ago and it already failed.
My computer still @oclif/core v1.16.7 locally, and it seems to work without problems.
To Reproduce Steps to reproduce the behavior:
npm install -g twilio-clitwilio plugins:install @twilio-labs/plugin-flextwilio profiles:create
I understand it would be more useful to provide a direct reproduction which only relies on oclif, but if there’s indeed an error in the code, it can hopefully be identified by the stack trace.
Expected behavior Commands run successfully.
Environment (please complete the following information):
- Ubuntu docker container with Node 16 installed, running on Github actions
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 16 (5 by maintainers)
Thanks for the context - I was able to reproduce it with the following:
I’ll report back once I know more about what’s causing this
I’ll get in touch with the respective team internally at Twilio. Thanks @mdonnalley !
@endreymarcell-wise @shrutiburman happy to help. I’m going to close this issue for now but feel free to reopen it if you feel it’s necessary
I am reproducing it on Ubuntu via Github Actions.
Yeah also facing the same issue. Build pipeline was successful in building using twilio-cli 3.4.1 yesterday. Tried the same build again today and got this error. Tried upgrading both flex-plugin and twilio-cli versions, but no success. Seems something has broken upstream, perhaps.