Skip to content

fix: keep settings on upgrade and fix provider, config and proxy bugs - #618

Merged
di-sukharev merged 17 commits into
masterfrom
fix/upgrade-and-providers
Nov 30, 2026
Merged

di-sukharev merged 17 commits into
masterfrom
fix/upgrade-and-providers

Conversation

@di-sukharev

Copy link
Copy Markdown
Owner

Why

The upgrade from 3.3.12 could leave users with broken settings. Several provider and config bugs also remained. This change fixes them before the next release.

Upgrade

  • Migration 03 keeps the default model of a removed provider, so the gateway gets the same model as before.
  • If oco config set replaces a removed provider with openai and sets OCO_API_URL, OpenCommit keeps the key.
  • OpenCommit reports a removed provider from the shell or .env before migrations and key checks. The Git hook gives the same advice.
  • The first run after an upgrade continues when no migration changes the config. Before, it always stopped.

Config and setup

  • oco setup clears a saved URL and its custom headers when it does not ask for a URL. Azure setup now asks for its endpoint.
  • oco config set shows which saved URL gets a new key, if the command sets no URL.
  • oco config set splits a value only at the first =, so headers and URLs that contain = are saved in full.
  • OCO_OLLAMA_THINK now works.

Providers and network

  • Each base URL has its own cached model list. An interrupted refresh no longer causes an error.
  • The library treats an undefined option as omitted.
  • HTTPS_PROXY and HTTP_PROXY follow NO_PROXY. OpenCommit warns about an unsupported value and connects directly. An unsupported OCO_PROXY gives an error.
  • The Azure provider supports OCO_PROXY, also in the library.
  • Ollama gets the configured API key. Custom Authorization headers take precedence.
  • A spent OpenAI quota is reported as insufficient credits, not as a rate limit.

Checks

Run locally on Node 24, with no network except loopback: lint, format check, build, 396 unit tests, the smoke and core e2e suites (2 and 91 tests). The Azure proxy tests check only the connection route.

🤖 Generated with Claude Code

The validator returned nothing, so `oco config set` saved `undefined`.
The environment mapping left the key out, so the shell and the
repository .env file could not set it either.
The removal message says to set OCO_AI_PROVIDER=openai and OCO_API_URL.
That command deleted the saved gateway key. Keep the key and the headers
when the same command sets OCO_API_URL. Without a URL, they are still
dropped, so the gateway key cannot go to OpenAI.
`oco config set` cut a value at its second "=". This broke keys that end
in "==", URLs with a query and headers that contain "=".
`oco config set OCO_API_KEY=...` keeps the saved OCO_API_URL, so that
gateway users can rotate a key. Say which URL receives the new key and
how to clear it. Leave out URL credentials and the query, which can
contain secrets. Print nothing for providers that never send the key to
OCO_API_URL.
Migration 03 saved only the gateway URL. Without a saved OCO_MODEL, the
openai default replaced the model of the gateway, which can lack it.
Save the model that the provider used in 3.3.12, and name it in the
removal message. A saved model stays unchanged. Migration 03 is not
released yet, so edit it in place.
Every new migration made the first `oco` after an upgrade exit with code
0 and no commit. Ask for a rerun only when the global config changed.
Otherwise record the migrations and continue.
A removed provider from the shell or the repository .env file led to
dead ends. Migration 00 failed after migration 03, the CLI asked for a
key for the removed provider, and the hook recommended a command that
OpenCommit rejects. Show how to replace the provider instead.
The cache used only the provider as its key, so it showed the models of
one endpoint for another. Use the provider and the base URL. Each fetch
function still calls the same host.

A version field lets OpenCommit ignore older files and the empty object
of an interrupted refresh, which crashed `oco models`.
Migration 03 turns a removed gateway into openai with the gateway URL. A
later `oco setup` with an OpenAI key kept that URL, so the new key went
to the gateway. Clear OCO_API_URL and OCO_API_CUSTOM_HEADERS when the
flow of the selected provider asks for no URL. An undefined change now
removes the key, because ini saves undefined as text.

The model list request already used the default host. A test now covers
it with the gateway models in the cache.
An option that a caller passed as undefined replaced its default. For
example, OCO_TOKENS_MAX_OUTPUT: undefined removed the output limit.
An HTTPS_PROXY or HTTP_PROXY such as socks5://127.0.0.1:1080 stopped
every engine. Warn once and connect directly, as 3.3.12 did.

Reject an unsupported OCO_PROXY with a clear error. Also block the
requests outside the engines, because direct ones would bypass the
proxy. The CLI does not exit at startup, so `oco config` can correct the
value and the hook cannot stop a commit.

NO_PROXY and no_proxy now apply to HTTPS_PROXY and HTTP_PROXY, for
example for a local Ollama. They do not apply to OCO_PROXY. The check
runs for each request. EnvHttpProxyAgent of undici is not used, because
it prints an experimental warning on every run.
The Azure SDK used only its own environment proxy. It ignored OCO_PROXY,
also when OCO_PROXY was null. Its proxy options are not enough: they
also apply NO_PROXY to an explicit proxy, and they cannot disable the
environment proxy. Replace the agent in a later policy instead. The
library now accepts OCO_PROXY for azure.
The README documents OCO_API_KEY for ollama, but the engine never sent
it. Send it as a Bearer token when it is set. A custom Authorization
header still takes precedence.
OpenAI returns 429 with the code insufficient_quota when the quota is
spent. OpenCommit told the user to wait, which does not help. Other 429
responses are still rate limits.
The proxy clients throw on a plain "%" in the credentials. Treat such a
URL like an unsupported protocol. HTTPS_PROXY or HTTP_PROXY then gives a
warning and a direct connection, as in 3.3.12, and OCO_PROXY gives a
clear error.
Azure has no default endpoint, and setup now clears a saved URL that it does not ask for.
@di-sukharev
di-sukharev merged commit b69d9f8 into master Nov 30, 2026
5 checks passed
@di-sukharev
di-sukharev deleted the fix/upgrade-and-providers branch December 1, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant