TencentCloud/TencentDB-Agent-Memory · error
No upstream response available
Error message
No upstream response available
What it means
forwardWithRetry in the MemoryProxy handler throws this when all forward attempts ended without producing an upstream HTTP response object. It signals the proxy could not obtain any response from the upstream LLM API to return to the caller, distinct from an explicit upstream failure. It is the terminal fallback after the retry loop exhausts candidates.
Source
Thrown at MemoryProxy/src/handler.ts:435
}
return { resp: upstreamResp, retried: true };
} catch (retryErr: unknown) {
if (isRateLimitExceededError(retryErr)) throw retryErr;
if (retryErr instanceof DOMException && retryErr.name === "TimeoutError") {
pipe.error("RETRY_FORWARD", `Timeout after ${forwardTimeoutMs / 1000}s`);
} else {
pipe.error("RETRY_FORWARD", retryErr);
}
throw new Error("Upstream request failed");
}
}
if (forwardFailed && !shouldRetry) {
throw new Error("Upstream request failed");
}
if (!upstreamResp) {
throw new Error("No upstream response available");
}
return { resp: upstreamResp, retried: false };
}
/** Main handler for POST /v1/chat/completions (OpenAI compat). */
export async function handleChatCompletions(
c: Context,
config: ProxyConfig,
): Promise<Response> {
const startTime = new Date().toISOString();
const traceId = uuidv7();
// ── Early auth ──────────────────────────────────────────────────────────
// Verify BEFORE parsing the body so a rejected caller never triggers body
// parsing or the alias-gate. `earlyVerify.userId` is reused later for
// both the systemUser short-circuit and the normal pipeline.
const earlyAuthHeader = c.req.header("authorization") ?? c.req.header("Authorization") ?? "";View on GitHub (pinned to 3efcd317b8)
Solutions
- Verify the proxy config defines at least one reachable upstream endpoint/api-key pair
- Inspect the forward loop logging to see why each attempt yielded no response object (timeouts, aborted requests)
- Ensure the upstream client throws instead of returning undefined on failure so the retry path classifies errors
- Add a health check / fallback upstream so at least one candidate is always available
Example fix
// before
const resp = await tryForward(url); // returns undefined on error
if (!upstreamResp) throw new Error("No upstream response available");
// after
const resp = await tryForward(url); // throws on error
if (!upstreamResp) throw new UpstreamUnavailableError("No upstream response after retries", attempts); Defensive patterns
Strategy: try-catch
Validate before calling
// before calling
if (!config.upstreams || config.upstreams.length === 0) {
throw new Error("proxy misconfigured: no upstream candidates configured");
} Type guard
function hasUpstreamResp(r: unknown): r is Response {
return r instanceof Response;
} Try / catch
try {
const { resp } = await forwardWithRetry(...);
} catch (e) {
if (e.message === "No upstream response available") {
return new Response(JSON.stringify({ error: "upstream_unavailable" }), { status: 502 });
}
throw e;
} Prevention
- Always configure at least one healthy upstream candidate
- Log each forward attempt's outcome to diagnose silent null responses
- Make upstream clients throw instead of returning undefined
- Add a 502 mapping in the route handler for this error
When it happens
Trigger: All upstream attempts failed without throwing a retryable 'Upstream request failed' path (forwardFailed false or shouldRetry true) yet upstreamResp remained undefined — e.g. every candidate upstream returned a null/undefined response object, or the forward loop completed with no attempts made because no upstream candidates were configured.
Common situations: Proxy config with an empty or misconfigured upstream list; upstream client returning undefined on swallowed errors; load-balancer candidate arrays filtered to zero entries after health checks.
Related errors
- Upstream request failed
- Upstream request failed
- llm.provider=proxy 需要 memory 系统用户 key —— 请在 yaml metadata.sy
- No upstream response available
- llm.provider=proxy 且 useMemorySystemUserKey=false 时必须显式 llm.
AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01).
Data as JSON: /api/errors/da52b4660c90c90f.
Report an issue: GitHub.