fix(proxy): deleting a proxy that no-auth accounts point to succeeds silently and sends them direct
OmniRoute Version
3.8.51 (release/v3.8.51, a58000c768)
Installation Method
Built from source
Operating System
Linux
Provider(s) Involved
Any no-auth provider using per-account proxies (opencode today).
Description
A no-auth account can point to a saved proxy by id (providerSpecificData.accountProxies[].proxyId). Two things go wrong once that proxy changes:
- Deleted proxy.
DELETE /api/settings/proxieschecks usage withgetProxyWhereUsed, which only readsproxy_assignments(src/lib/db/proxies.ts:700-725). A proxy referenced only by accounts is deleted without the usual 409proxy_in_use, and nothing warns. On the next request the id no longer resolves and the account falls back toproxy: null(src/sse/services/noAuthProxyResolution.ts:21-24,89-100): its traffic now leaves from the host's own address, although the operator configured a proxy for it. - Deactivated proxy. The by-id lookup reads the row whatever its status (
src/lib/db/proxies.ts:285-300), so an account keeps sending through a proxy markedinactive, which pools already skip (PROXY_ALIVE_PREDICATE,src/lib/db/proxies/rotation.ts). Every request pays the failure before anything else happens.
Steps to Reproduce
- Save a proxy and select it for one account on a no-auth connection's account card (stored by id).
- Delete that proxy with
DELETE /api/settings/proxies?id=<id>, withoutforce. - Send a request that this account serves.
Expected Behavior
Step 2 returns 409 proxy_in_use, as for a proxy assigned to a scope. If the proxy is gone anyway, the account never sends without a proxy.
Actual Behavior
Step 2 succeeds. At step 3 the account resolves to proxy: null and the request leaves from the host address.
Proposed Fix
- Count
accountProxiesreferences ingetProxyWhereUsed, so deleting such a proxy returns the same 409 as any other assigned proxy; withforce=true, clear those references and log which accounts lost their proxy. - When an account's proxy id is unknown or its proxy is not alive, treat it the way a dead pool is treated (#6246): don't send direct; skip the account and log why.
Alternatives considered: keeping the direct fallback with a warning (the traffic still leaves from the host address); reassigning the account to another saved proxy automatically (a bigger behaviour change, better discussed separately).
Test Impact
Unit: usage count includes account references; delete without force returns 409; unknown and inactive ids resolve to "skip", not direct. Integration: after a forced delete, no request for that account leaves without a proxy. Accounts with no proxy configured at all keep today's behaviour.
Source: diegosouzapw/OmniRoute