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

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

Open
funkyfisch opened this issue May 31, 2024 · 11 comments
Labels
bug Something isn't working

Comments

@funkyfisch
Copy link

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

@funkyfisch funkyfisch added the bug Something isn't working label May 31, 2024
@codemile
Copy link

codemile commented Jun 5, 2024

This is reproducible for new users.

@di-sukharev
Copy link
Owner

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

@codemile
Copy link

codemile commented Jun 5, 2024

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

@codemile
Copy link

codemile commented Jun 5, 2024

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

> [email protected] 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
Copy link

It seems the best fix is to roll back to 3.0.11

npm i [email protected] -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
Copy link

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
Copy link

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

@heristop
Copy link

heristop commented Jul 4, 2024

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

@zhangwinning
Copy link

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

izzybps added a commit to izzybps/opencommit that referenced this issue Jul 31, 2024
…string to undefined resolving di-sukharev#352 - creates invalid config file
di-sukharev added a commit that referenced this issue Aug 13, 2024
* 📝 (README.md): add support for custom AI models and update documentation to reflect new environment variable OCO_ AI_PROVIDER (#351)

* Feat/add gemini (#349)

* 🐛Fix: prompt-module/@commitlint (#336)

* fix(commitlint/utils.ts): correct variable used in search for JSON block end tag

* ♻️ (commitlint/config.ts & pwd-commitlint.ts): Refactor commitlint config loading to support both CJS and ESM modules

💡 (pwd-commitlint.ts): Add detailed comments and error handling for better clarity and robustness in commitlint module loading process

* ✨ (package.json): Add setup script for e2e tests to install dependencies for commitlint configurations
🔧 (setup.sh): Add shell script to set up commitlint configurations for e2e tests

* ✨ (config.ts): Add support for OCO_TEST_MOCK_TYPE configuration key to define test mock type for testing purposes
📝 (config.ts): Update documentation for OCO_TEST_MOCK_TYPE configuration key in configValidators and getConfig functions
📝 (testAi.ts): Add TEST_MOCK_TYPES constant array to define supported test mock types
📝 (testAi.ts): Update generateCommitMessage function to use OCO_TEST_MOCK_TYPE from config for different test mock types
📝 (commitlint.test.ts): Add e2e test for running "oco commitlint force" with different @commitlint versions using CJS and ESM
📝 (utils.ts): Add wait function to introduce delay in milliseconds for testing purposes

* ✨ (commitlint.test.ts): refactor setupCommitlint function to accept a version parameter for better code organization and readability
📝 (commitlint.test.ts): add test case for commitlint@9 using CJS to ensure proper functionality and compatibility
📝 (commitlint.test.ts): add test case for commitlint@18 using CJS to ensure proper functionality and compatibility
📝 (commitlint.test.ts): add test case for commitlint@19 using ESM to ensure proper functionality and compatibility

* 🔧 (commitlint.test.ts): remove unnecessary commands to create and add index.ts file before running tests

* refactor(test/e2e/prompt-module/commitlint.test.ts): remove unused import configure
style(test/e2e/prompt-module/commitlint.test.ts): add missing semicolon for consistency
test(test/e2e/prompt-module/commitlint.test.ts): add e2e tests for @commitlint prompt-module integration

* ✨ (e2e tests): add package.json copying to setupCommitlint for version accuracy
♻️ (commitlint config): refactor commitlint.config.js to use ES module syntax
✨ (package.json): specify "type": "module" to support ES module syntax

* docs: spelling fix (#325)

* 3.0.17

* ♻️ (config.ts): refactor OCO_AZURE_ENDPOINT default value from empty string to undefined resolving #352 - creates invalid config file

---------

Co-authored-by: tumf <[email protected]>
Co-authored-by: Drew Payment <[email protected]>
Co-authored-by: Takanori Matsumoto <[email protected]>
Co-authored-by: Kellan Stevens <[email protected]>
Co-authored-by: di-sukharev <[email protected]>
@di-sukharev
Copy link
Owner

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

@di-sukharev
Copy link
Owner

done, please @funkyfisch follow up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants