mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-26 00:52:18 +03:00
⭐5 — Fix(#10967,#10966): combo diag exhausted_connection truncava o UUID por hardcode de provider="unknown"; recovery hint de quota caía em "retry" genérico. TDD RED→GREEN, 149 testes-irmãos verdes. UNSTABLE é o base-red inherited #9985.
30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
/**
|
|
* #10967: format an `exhaustedConnections` key stored by targetExhaustion.ts
|
|
* (`markAuthLevelExhaustion` / `markAgentrouterConnectionQuotaExhaustion` /
|
|
* `markConnectionLevelExhaustion`, all keyed as `` `${provider}:${connectionId}` ``)
|
|
* into a diagnostics `excluded` entry.
|
|
*
|
|
* Before this fix, `buildComboDiag` (combo.ts) hardcoded `provider: "unknown"` and
|
|
* `slice(0, 8)`'d the WHOLE key — for a typical `jina-ai:<uuid>` key that produced
|
|
* `exhausted_connection:jina-ai:` (the 7-char provider id + colon consumed the
|
|
* entire 8-char budget, the UUID silently dropped, and the real provider id
|
|
* discarded in favor of the literal string "unknown").
|
|
*
|
|
* Splitting on the FIRST `:` recovers the real provider id and truncates only the
|
|
* connection-id half (never the full UUID, matching the public combo projection's
|
|
* connection-id redaction policy — #2300).
|
|
*/
|
|
export function formatExhaustedConnectionKey(key: string): {
|
|
provider: string;
|
|
reason: string;
|
|
} {
|
|
const raw = String(key);
|
|
const sepIdx = raw.indexOf(":");
|
|
const provider = sepIdx >= 0 ? raw.slice(0, sepIdx) : "";
|
|
const connId = sepIdx >= 0 ? raw.slice(sepIdx + 1) : raw;
|
|
return {
|
|
provider: provider || "unknown",
|
|
reason: `exhausted_connection:${connId.slice(0, 8)}`,
|
|
};
|
|
}
|