TencentCloud/TencentDB-Agent-Memory · error · CoreUpstreamError
CORE_UPSTREAM_ERROR
CORE_UPSTREAM_ERROR
Error message
json.message || `core error code ${json.code}` What it means
The HTTP knowledge client wraps every core (wiki) API call in an envelope check: when the JSON body carries a non-zero `code`, the client throws CoreUpstreamError('CORE_UPSTREAM_ERROR'). The HTTP status is mapped to resp.status when >= 400, otherwise 502, and the message is taken from the core's `message` field. This is the standard path for business-level failures returned by the core service.
Source
Thrown at MemoryPanel/src/panel/kernel/adapters/http-knowledge-client.ts:67
export class HttpKnowledgeClient implements KnowledgeClientPort {
constructor(private readonly cfg: KnowledgeClientConfig) {}
private async post<T>(path: string, body: unknown): Promise<T> {
const ctrl = new AbortController();
const timer = setTimeout(() => ctrl.abort(), this.cfg.timeoutMs ?? 15_000);
try {
const headers: Record<string, string> = { 'Content-Type': 'application/json' };
if (this.cfg.authToken) headers.Authorization = `Bearer ${this.cfg.authToken}`;
if (this.cfg.serviceId) headers['x-tdai-service-id'] = this.cfg.serviceId;
const resp = await fetch(`${this.cfg.baseUrl}${path}`, {
method: 'POST',
headers,
body: JSON.stringify(body),
signal: ctrl.signal,
});
const json = (await resp.json()) as CoreEnvelope<T>;
if (json.code !== undefined && json.code !== 0) {
throw new CoreUpstreamError(
'CORE_UPSTREAM_ERROR',
resp.status >= 400 ? resp.status : 502,
json.message || `core error code ${json.code}`,
json.code,
);
}
if (!resp.ok) {
throw new CoreUpstreamError('CORE_UPSTREAM_ERROR', resp.status, json.message || `HTTP ${resp.status}`, 0);
}
return json.data as T;
} finally {
clearTimeout(timer);
}
}
// ═══════════════ Wiki · 资产层 ═══════════════
async wikiCreate(teamId: string, name: string, userId?: string): Promise<WikiDetail> {View on GitHub (pinned to 3efcd317b8)
Solutions
- Read error.code and error.message from the thrown CoreUpstreamError and act on the specific core error code
- Confirm the core service version matches what this client expects (schema drift)
- Check core service logs for the request_id to find the underlying failure
- Retry idempotent calls (wikiGet, wikiList) if the core code indicates a transient condition
Example fix
// before
try { await client.wikiIngest(body); } catch (e) { console.error(e); }
// after
try { await client.wikiIngest(body); } catch (e) {
if (e instanceof CoreUpstreamError) console.error(`core code=${e.code} status=${e.status}: ${e.message}`);
else throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight reachability check
const ping = await fetch(`${coreBaseUrl}/health`);
if (!ping.ok) throw new Error(`core unreachable: HTTP ${ping.status}`); Type guard
class CoreUpstreamError extends Error {
constructor(public name_: 'CORE_UPSTREAM_ERROR', public status: number, message: string, public code: number) { super(message); }
}
function isCoreUpstreamError(e: unknown): e is CoreUpstreamError {
return e instanceof CoreUpstreamError;
} Try / catch
try {
const doc = await client.wikiGet(id);
} catch (e) {
if (isCoreUpstreamError(e)) {
console.error(`core error code=${e.code} http=${e.status}: ${e.message}`);
} else throw e;
} Prevention
- Inspect e.code/e.status on CoreUpstreamError before generic handling
- Keep core client and core service versions in sync
- Health-check the core service before batch wiki operations
- Retry only idempotent wiki calls (get/list) on transient codes
When it happens
Trigger: Any of wikiCreate, wikiGet, wikiIngest, wikiDelete, wikiList, wikiRawLs receiving a JSON envelope with code !== 0 and code !== undefined from the core HTTP endpoint — e.g. document not found, invalid ingest payload, auth rejection at the core level, or core-internal error with a JSON body.
Common situations: Core service returning structured error envelopes during downtime or schema changes; stale wiki document IDs after a core rebuild; core rejecting payloads after a version upgrade changed required fields.
Related errors
- agent-fixed-asset/set failed: ${setEnv.code}
- Upstream request failed
- No upstream response available
- Upstream request failed
- No upstream response available
AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01).
Data as JSON: /api/errors/dae1e11068fc848f.
Report an issue: GitHub.