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

git-cz fails with "Cannot convert undefined or null to object" #227

Closed
rileyjshaw opened this issue Nov 25, 2020 · 12 comments · Fixed by #267
Closed

git-cz fails with "Cannot convert undefined or null to object" #227

rileyjshaw opened this issue Nov 25, 2020 · 12 comments · Fixed by #267
Labels

Comments

@rileyjshaw
Copy link

I just migrated my personal site (repo, in case config is relevant) to a new machine. git-cz is failing with the following trace:

> [email protected] commit /Users/rjs/code/rileyjshaw
> git-cz --disable-emoji

[email protected], [email protected]

(node:11594) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at runInteractiveQuestions (/Users/rjs/code/rileyjshaw/node_modules/git-cz/dist/cz.js:576:10)
    at run (/Users/rjs/code/rileyjshaw/node_modules/git-cz/dist/cz.js:157:11)
    at exports.prompter (/Users/rjs/code/rileyjshaw/node_modules/git-cz/dist/cz.js:164:3)
    at /Users/rjs/code/rileyjshaw/node_modules/commitizen/dist/commitizen/commit.js:598:9
    at /Users/rjs/code/rileyjshaw/node_modules/fs-extra/lib/mkdirs/mkdirs.js:56:16
    at callback (/Users/rjs/code/rileyjshaw/node_modules/graceful-fs/polyfills.js:295:20)
    at FSReqCallback.oncomplete (fs.js:184:5)

I followed this back to runInteractiveQuestions.js. cliAnswers is undefined, so,

const runInteractiveQuestions = async (state, cliAnswers) => {
  Object.keys(cliAnswers).forEach((key) => {

fails. I'm confused because in cz.js,

    await runInteractiveQuestions(state);

runInteractiveQuestions is called with a single argument. But this was passing before, so I'm sure I've made a simple configuration mistake.

I'm stuck debugging this, so any advice is appreciated.

For what it's worth, I tested this on:

  • npm v7.0.8, Node v15.2.1
  • npm v6.14.8, Node v14.15.1
@rodrigograca31
Copy link
Collaborator

can you please try 4.7.1 and tell us if the problem still exists?

npm i [email protected] -g

I merged a PR in 4.7.2 related to --dissable-emoji ....
https://github.com/streamich/git-cz/releases/tag/v4.7.2

@rileyjshaw
Copy link
Author

rileyjshaw commented Dec 1, 2020

I'm still seeing Cannot convert undefined or null to object on 4.7.1. I'm using this with commitizen by the way, so I skipped the -g in your snippet above. Let me know if I'm missing something, or if there's more I can help with on my end :)

@rileyjshaw
Copy link
Author

I just updated to the latest version and I'm not seeing this error anymore – thank you!

@rileyjshaw
Copy link
Author

I'm seeing this again on a fresh install of 4.7.6.

@rileyjshaw rileyjshaw reopened this Jan 21, 2021
@rileyjshaw
Copy link
Author

For testing, I dropped back to a previous version:

npm i [email protected]

and it's working as expected. Looks like there may be a regression.

rileyjshaw added a commit to rileyjshaw/rileyjshaw.github.io that referenced this issue Mar 7, 2021
rileyjshaw added a commit to rileyjshaw/rileyjshaw.github.io that referenced this issue Mar 7, 2021
@petermetz
Copy link

Hit the same issue, multiple times with it disappearing and then resurfacing with different versions as well, made no sense.

So, I started checking other things and found out that I also had commitizen installed which for some reason declares it's own, conflicting binary also called git-cz that (I'm guessing) may end up being hooked up to ./node_modules/.bin/git-cz randomly depending on the cookie crumbles when you run npm install (which I assume does as much as possible parallelized)

Uninstalled commitizen and right now it's working. Just a theory, but maybe it's right.
@rileyjshaw have you also been using commitizen at the same time as git-cz?

@nonameolsson
Copy link

nonameolsson commented May 2, 2021

I have been following this discussion for a while and just wanted to fill in.

I've had commitizen installed, and sometimes I've had this error. Maybe you are on to something @petermetz 👍

Hit the same issue, multiple times with it disappearing and then resurfacing with different versions as well, made no sense.

So, I started checking other things and found out that I also had commitizen installed which for some reason declares it's own, conflicting binary also called git-cz that (I'm guessing) may end up being hooked up to ./node_modules/.bin/git-cz randomly depending on the cookie crumbles when you run npm install (which I assume does as much as possible parallelized)

Uninstalled commitizen and right now it's working. Just a theory, but maybe it's right.

@rileyjshaw have you also been using commitizen at the same time as git-cz?

@rileyjshaw
Copy link
Author

@rileyjshaw have you also been using commitizen at the same time as git-cz?

Yes, I’ve also been using commitizen.

@petermetz
Copy link

Alright, then we are probably onto something. I'll head over to the commitizen repo and file a bug. It would be a breaking change for them to remove their alias (even if they agree to it) but at least we should discuss it. All this assuming of course that the root cause really is commitizen, but the circumstantial evidence definitely points in that direction.

@zhang-xianlei
Copy link

I just migrated my personal site (repo, in case config is relevant) to a new machine. git-cz is failing with the following trace:

> [email protected] commit /Users/rjs/code/rileyjshaw
> git-cz --disable-emoji

[email protected], [email protected]

(node:11594) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at runInteractiveQuestions (/Users/rjs/code/rileyjshaw/node_modules/git-cz/dist/cz.js:576:10)
    at run (/Users/rjs/code/rileyjshaw/node_modules/git-cz/dist/cz.js:157:11)
    at exports.prompter (/Users/rjs/code/rileyjshaw/node_modules/git-cz/dist/cz.js:164:3)
    at /Users/rjs/code/rileyjshaw/node_modules/commitizen/dist/commitizen/commit.js:598:9
    at /Users/rjs/code/rileyjshaw/node_modules/fs-extra/lib/mkdirs/mkdirs.js:56:16
    at callback (/Users/rjs/code/rileyjshaw/node_modules/graceful-fs/polyfills.js:295:20)
    at FSReqCallback.oncomplete (fs.js:184:5)

I followed this back to runInteractiveQuestions.js. cliAnswers is undefined, so,

const runInteractiveQuestions = async (state, cliAnswers) => {
  Object.keys(cliAnswers).forEach((key) => {

fails. I'm confused because in cz.js,

    await runInteractiveQuestions(state);

runInteractiveQuestions is called with a single argument. But this was passing before, so I'm sure I've made a simple configuration mistake.

I'm stuck debugging this, so any advice is appreciated.

For what it's worth, I tested this on:

  • npm v7.0.8, Node v15.2.1
  • npm v6.14.8, Node v14.15.1

I just updated to the latest version and I'm not seeing this error anymore – thank you!

I also face the same problem as yours. Can you tell me you device OS, windows or macos?
My device is win10, And I set the git-cz version to 4.7.1, but the problem is still there.
Thank you!

streamich pushed a commit that referenced this issue Oct 13, 2021
# [4.8.0](v4.7.6...v4.8.0) (2021-10-13)

### Bug Fixes

* 🐛 give default value to prevent convert error ([c16df5d](c16df5d)), closes [#227](#227)
* better support for workspaces ([215b6c3](215b6c3))

### Features

* 🎸 add "format" field to customize subject in commit msg [#81](#81) ([5e998cf](5e998cf))
* 🎸️ format (custom message) ([6f0c828](6f0c828))
@streamich
Copy link
Owner

🎉 This issue has been resolved in version 4.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@zhang-xianlei
Copy link

Thank you!

rileyjshaw added a commit to rileyjshaw/rileyjshaw.github.io that referenced this issue Jan 10, 2024
github-actions bot pushed a commit to damdauvaotran/git-cz that referenced this issue Jan 6, 2025
# 1.0.0 (2025-01-06)

### Bug Fixes

* 🐛 add config option to change closed issue message ([streamich#218](https://github.com/damdauvaotran/git-cz/issues/218)) ([dd88ce9](dd88ce9)), closes [streamich#215](https://github.com/damdauvaotran/git-cz/issues/215)
* 🐛 add extra space after emoji ([47a746a](47a746a))
* 🐛 Adhere to lerna settings for workspaces directory ([4151235](4151235)), closes [streamich#85](https://github.com/damdauvaotran/git-cz/issues/85)
* 🐛 Allow usage of package on win32 ([41c2170](41c2170)), closes [streamich#21](https://github.com/damdauvaotran/git-cz/issues/21)
* 🐛 check for staged files ([78dec95](78dec95))
* 🐛 disable-emoji config being overwritten by default ([streamich#211](https://github.com/damdauvaotran/git-cz/issues/211)) ([eb9eb06](eb9eb06)), closes [streamich#207](https://github.com/damdauvaotran/git-cz/issues/207)
* 🐛 do not format body as undefined ([28d6e77](28d6e77))
* 🐛 don't add emoji to head only when "disableEmoji" is true ([45489c8](45489c8))
* 🐛 don't ask Lerna question, if Lerna not installed ([843093c](843093c))
* 🐛 failing test (execSync not defined) ([b9b6969](b9b6969))
* 🐛 Fix COMMIT_EDITMSG in bare repositories ([008ee31](008ee31))
* 🐛 fix git commit error ([b116ba0](b116ba0))
* 🐛 fix lerna question all package list ([74581de](74581de))
* 🐛 Fix use wrong number of regex matches ([da09545](da09545))
* 🐛 Fix wrong order of declare var ([045cf26](045cf26))
* 🐛 fix: don't fail if config missing in package.json ([a4a010d](a4a010d))
* 🐛 fixes autocomplete prompt import ([91226ba](91226ba))
* 🐛 fixes scope's empty string answer issue ([53dd466](53dd466))
* 🐛 give default value to prevent convert error ([c16df5d](c16df5d)), closes [streamich#227](https://github.com/damdauvaotran/git-cz/issues/227)
* 🐛 ignore "staged files check" when -a or --amend is passed ([206274f](206274f)), closes [streamich#189](https://github.com/damdauvaotran/git-cz/issues/189)
* 🐛 make semantic-release publish to NPM ([6f5c836](6f5c836))
* 🐛 move check for git folder to top ([cdf142c](cdf142c))
* 🐛 multiple lines on Windows ([streamich#210](https://github.com/damdauvaotran/git-cz/issues/210)) ([838d47b](838d47b)), closes [streamich#188](https://github.com/damdauvaotran/git-cz/issues/188) [streamich#197](https://github.com/damdauvaotran/git-cz/issues/197)
* 🐛 pad-right ([1891a62](1891a62))
* 🐛 pad-right ([94b063c](94b063c))
* 🐛 Read git-cz config from package.json ([c72cfac](c72cfac))
* 🐛 simplify semantic-release config ([3872978](3872978))
* 🐛 test when in --dry-run mode ([1697c56](1697c56))
* 🐛 use process.platform to check for platform ([be13775](be13775))
* 🐜 simplify package.json ([ea20619](ea20619))
* 🐜 Updated bug emoji ([e81dd66](e81dd66))
* 🐞 README fixes ([ee33460](ee33460))
* actually return execSync() result ([9321454](9321454)), closes [streamich#19](https://github.com/damdauvaotran/git-cz/issues/19)
* better support for workspaces ([215b6c3](215b6c3))
* build binaries on Travis ([10194a8](10194a8))
* fix typo ([548f978](548f978))
* manually update version ([811025c](811025c))
* release revert of checking for staged files ([8a6ac6e](8a6ac6e))
* remove emojis when disableEmoji is true ([62915be](62915be))
* trigger again ([ee4cf18](ee4cf18))
* trigger new release ([5457be9](5457be9))
* Windows support ([bcc3525](bcc3525)), closes [#12](#12)

### Continuous Integration

* 🎡 remove NPM semantic-release plugin for on release ([a9f23eb](a9f23eb))

* [add-check-home-config] feat: 🎸 Update version ([41a8282](41a8282))

### Features

* 🎸 add --disable-emoji to --help and parse from CLI ([82dd0c9](82dd0c9))
* 🎸 add "format" field to customize subject in commit msg [streamich#81](https://github.com/damdauvaotran/git-cz/issues/81) ([5e998cf](5e998cf))
* 🎸 add back Lerna support ([879d9c1](879d9c1))
* 🎸 add binary git-cz command for CLI ([3d11bdd](3d11bdd))
* 🎸 add disable emoji flag ([52a43d9](52a43d9))
* 🎸 add dry-run mode ([395c0c7](395c0c7))
* 🎸 add emojis to BREAKING CHANGE and closed issue sections ([5e6dc17](5e6dc17))
* 🎸 add help & version flags ([799fff2](799fff2))
* 🎸 add mmarkdown ([323f0e8](323f0e8))
* 🎸 add signale for error logging ([9aea7b2](9aea7b2))
* 🎸 added disableEmojis on config ([448873e](448873e))
* 🎸 adds a feature to search for types ([f8c3452](f8c3452))
* 🎸 adds git hooks support ([80176cd](80176cd)), closes [streamich#79](https://github.com/damdauvaotran/git-cz/issues/79)
* 🎸 adds scope search in scopes question ([70bf18b](70bf18b))
* 🎸 Allow emojis in non-interactive and set defaults ([08cf19c](08cf19c))
* 🎸 build binaries ([0a64804](0a64804))
* 🎸 can set answers through CLI in default mode ([99238c2](99238c2))
* 🎸 check for staged files ([c283ad3](c283ad3))
* 🎸 connect new interface to commitizen ([3dd3c67](3dd3c67))
* 🎸 execute standalone CLI commit ([8570804](8570804))
* 🎸 exit process when no files staged ([9fb4844](9fb4844))
* 🎸️ format (custom message) ([6f0c828](6f0c828))
* 🎸 improve help screen ([1838c1c](1838c1c))
* 🎸 make changelog config customizable ([1758b94](1758b94))
* 🎸 make LimitedInput work with new inquirer ([065bfae](065bfae))
* 🎸 manually bump version ([fb05bfb](fb05bfb))
* 🎸 non-interactive mode ([61b40db](61b40db))
* 🎸 recursively search parent folders for config file ([ce04676](ce04676)), closes [streamich#60](https://github.com/damdauvaotran/git-cz/issues/60)
* 🎸 show nice error message when Git root not found ([54ed319](54ed319))
* 🎸 support cjs config files ([4f2ebc5](4f2ebc5))
* 🎸 update emoji icons ([9e29df4](9e29df4))
* 🎸 use "closes" keywoard to close GitHub issues ([bb89aec](bb89aec)), closes [streamich#123](https://github.com/damdauvaotran/git-cz/issues/123)
* add commitizen prompter ([89b4dac](89b4dac))
* add custom limited input component ([1ba869a](1ba869a))
* add default scopes ([1be406f](1be406f))
* add emojis to commit message ([2c36297](2c36297))
* add scope to subject input ([f942494](f942494))
* add support for lerna mono-repos ([11cbde4](11cbde4))
* autofix header case ([238dd6f](238dd6f))
* Check commit subject for minimum length ([9f41dbf](9f41dbf))
* create formatMessage() function ([d1c6755](d1c6755))
* display emoji in selection list ([3e2e57b](3e2e57b))
* initial commit ([18ccbd9](18ccbd9))
* refactor questions out ([5212e93](5212e93))
* removed question mark if no emojis are configured ([212c172](212c172)), closes [#9](#9)
* show line prefixes added by the adapter ([c6202fe](c6202fe))
* simplify messages, increase line length ([909bae6](909bae6))
* store answers in state ([3110e94](3110e94))
* try to release new version from Travis ([b6e5a5e](b6e5a5e))
* use fuzzy search for scopes and types ([e6d615f](e6d615f))
* use Git to determine root folder ([d59dbd4](d59dbd4))

### Performance Improvements

* ⚡️ build cz prompter into one file  for performace ([dd62d93](dd62d93))
* ⚡️ bundle into single .js file for perf ([a7738c8](a7738c8))
* ⚡️ remove all deps so nothing is installed ([16ce6a7](16ce6a7))

### BREAKING CHANGES

* 🧨 gpsup
* 🧨 Release new major
* 🧨 test

✅ Closes: test
* "closes" keyboard is used instead of "issues", which will close GitHub
issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants