di-sukharev / opencommit

Generate conventional git commit messages with AI in 1 second 🤯🔫
https://www.npmjs.com/package/opencommit
MIT License
6.15k stars 328 forks source link

[Bug]: Unsupported config key OCO_AZURE_ENDPOINT - even when provider is set to openai #352

Open funkyfisch opened 5 months ago

funkyfisch commented 5 months ago

Opencommit Version

3.0.16

Node Version

v21.6.2

NPM Version

10.2.4

What OS are you seeing the problem on?

Other Linux Distro

What happened?

installing oco fresh, setting openai api key and running oco set hook. Any further invocations of oco (including the hook itself) just fail with Unsupported config key OCO_AZURE_ENDPOINT: Must be in format "https://<resource name>.openai.azure.com/"

I managed to bypass this by modifying the .opencommit file in the home directory and add "undefined" as a value to the OCO_AZURE_ENDPOINT key (which was empty)

Expected Behavior

Unnecessary variables should not break the programs functionality. I couldn't even set/unset the value using the cli because of this error.

Current Behavior

oco refuses to do anything until this is fixed manually. this is similar to this earlier issue

Possible Solution

Parse the variables first, and then have a dependency graph among them. based on that dependency graph, sanitize accordingly based on what is needed. Also make sure to allow higher level commands (like oco config) to still work even if variables are set incorrectly in the autogenerated file. Finally to fix the specific bug, make sure to populate it with undefined, similarly to how the rest of the variables are.

Steps to Reproduce

No response

Relevant log output

No response

codemile commented 5 months ago

This is reproducible for new users.

di-sukharev commented 5 months ago

any volunteers to make a PR? i could not find any existing one

codemile commented 5 months ago

@di-sukharev I'll give a try and open a PR today.

codemile commented 5 months ago

I'm running Node v20.14.0 with npm v10.7.0 but the project won't run. Is this a known issue?

$ npm run dev

> opencommit@3.0.16 dev
> ts-node ./src/cli.ts

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /opencommit/src/cli.ts
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
    at defaultLoad (node:internal/modules/esm/load:143:22)
    at async nextLoad (node:internal/modules/esm/hooks:866:22)
    at async nextLoad (node:internal/modules/esm/hooks:866:22)
    at async Hooks.load (node:internal/modules/esm/hooks:449:20)
    at async MessagePort.handleMessage (node:internal/modules/esm/worker:196:18) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
bearjaws commented 5 months ago

It seems the best fix is to roll back to 3.0.11

npm i opencommit@3.0.11 -g

then open your config and ensure you delete the OCO_GITPUSH parameter, otherwise you will get a parse error.

└ Unknown 'OCO_GITPUSH' config option.

Works fine with OCO_MODEL=gpt-3.5-turbo

NodeJSmith commented 4 months ago

FWIW the issue seems to be caused by the entire config file being written, even empty/unset parameters, whenever any config value is set. So if you want to avoid rolling back you can edit ~/.opencommit and remove all of the empty/unset config values and it should work again.

aryasena0 commented 4 months ago

I got the same output after installing opencommit on my new device

heristop commented 4 months ago

I confirm @NodeJSmith answer. You should edit the config file in ~/.opencommit and remove the line with OCO_AZURE_ENDPOINT=

zhangwinning commented 4 months ago

I confirm @NodeJSmith answer. You should edit the config file in ~/.opencommit and remove the line with OCO_AZURE_ENDPOINT=我确认答案。您应该编辑 ~/.opencommit 中的配置文件并删除 OCO_AZURE_ENDPOINT= 行

very nice

di-sukharev commented 3 months ago

the PR was merged, gonna be released in the next version today

di-sukharev commented 3 months ago

done, please @funkyfisch follow up