TencentCloud/TencentDB-Agent-Memory · error

${TAG} ${path} HTTP ${resp.status}${detail ? `: ${detail.sli

Error message

${TAG} ${path} HTTP ${resp.status}${detail ? `: ${detail.slice(0, 200)}` : ""}

What it means

MetaClient.fetch throws this when the metadata service responds with a non-2xx HTTP status. The message includes path, status code, and up to 200 chars of the response body as detail, so it carries the server's own error explanation. This is the 'server rejected the request' error, distinct from transport failures and envelope-level business errors.

Source

Thrown at MemoryProxy/src/meta/client.ts:553

      resp = await this.fetcher(url, {
        method: "POST",
        headers,
        body: JSON.stringify(body),
        signal: AbortSignal.timeout(this.defaultTimeoutMs),
      });
    } catch (err) {
      throw new Error(`${TAG} ${path} fetch failed: ${(err as Error).message}`);
    }

    if (!resp.ok) {
      let detail = "";
      try {
        detail = await resp.text();
      } catch { /* ignore */ }
      console.log(
        `[wb-debug] metadata-client req path=${path} status=${resp.status} url=${url} serviceId=${this.serviceId} userKey.len=${this.userKey?.length ?? 0} userKey.prefix=${(this.userKey ?? "").slice(0, 20)} serviceToken.len=${this.serviceToken?.length ?? 0} body.len=${detail.length} body.head=${detail.slice(0, 300)}`,
      );
      throw new Error(`${TAG} ${path} HTTP ${resp.status}${detail ? `: ${detail.slice(0, 200)}` : ""}`);
    }

    const env = (await resp.json()) as CoreEnvelope<T>;

    if (env.code !== 0) {
      throw new Error(`${TAG} ${path} envelope error ${env.code}: ${env.message ?? ""}`);
    }

    if (env.data === null || env.data === undefined) {
      throw new Error(`${TAG} ${path} unexpected null data`);
    }

    return env.data as T;
  }
}

// ── Singleton + test injection ──────────────────────────────────────────────

View on GitHub (pinned to 3efcd317b8)

Solutions

  1. Read the detail/status in the message (and the [wb-debug] log line) to identify the exact rejection reason
  2. For 401/403, refresh serviceToken and verify userKey/serviceId configuration
  3. For 400, validate the payload against the service schema before calling
  4. For 5xx/429, retry with exponential backoff; check service health dashboards

Example fix

// before
await client.createTask({ title }); // 403: bad token
// after
await ensureTokenValid(); // refresh serviceToken before metadata calls
await client.createTask({ title });
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-validate auth inputs before the call
if (!userKey || !serviceToken) throw new Error("missing userKey/serviceToken for metadata client");

Type guard

function isHttpError(e: unknown): e is Error & { path: string; status: number } {
  const m = e instanceof Error && /HTTP \d{3}/.exec(e.message);
  return !!m;
}

Try / catch

try {
  await client.updateTask(id, patch);
} catch (e) {
  const m = /HTTP (\d{3})/.exec(e instanceof Error ? e.message : "");
  if (m) {
    const status = Number(m[1]);
    if (status === 401 || status === 403) await refreshToken();
    else if (status >= 500 || status === 429) await backoffRetry();
    else throw e; // 4xx: do not retry
  } else throw e;
}

Prevention

When it happens

Trigger: createTask/updateTask/appendParticipationLog receives resp.ok === false — e.g. 401/403 for bad userKey/serviceToken, 404 wrong path, 400 malformed body, 5xx service error. The [wb-debug] console log prints full request context before throwing.

Common situations: Expired or wrong service token / user key (401/403); API version path changed; sending a body the service's schema rejects (400); rate limiting at the gateway (429).

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01). Data as JSON: /api/errors/66363da36f324775. Report an issue: GitHub.