TencentCloud/TencentDB-Agent-Memory · critical · SkillCoreError

SKILL_COS_REQUIRED

SKILL_COS_REQUIRED

Error message

contentBackend=cos required but COS credentials missing (secretId / secretKey / bucket). Verify Shark COS config or cos.env in service mode — refusing to silently fall back to local fs.

What it means

resolveSkillConfig enforces that when contentBackend is explicitly set to "cos" (Tencent Shark COS object storage), COS credentials (secretId, secretKey, bucket) must actually be present. In strict mode, instead of silently degrading to the local filesystem, it throws SkillCoreError with code SKILL_COS_REQUIRED so misconfiguration is surfaced immediately.

Source

Thrown at MemoryCore/src/core/skill/skill-config.ts:99

      from: "tcvdb",
      to: "sqlite",
      reason: "TCVDB credentials missing (url / apiKey / database)",
      level: "warn",
    });
    logger.warn(
      `${TAG} storeBackend=tcvdb requested but credentials missing — degrading to sqlite`,
    );
    storeBackend = "sqlite";
  }

  // --------------- content ---------------
  const explicitContent = input.contentBackend;
  let contentBackend: "local" | "cos";
  if (explicitContent === "cos") {
    if (probe.hasCosCredentials) {
      contentBackend = "cos";
    } else if (strictMode) {
      throw new SkillCoreError(
        "SKILL_COS_REQUIRED",
        "contentBackend=cos required but COS credentials missing (secretId / secretKey / bucket). " +
          "Verify Shark COS config or cos.env in service mode — refusing to silently fall back to local fs.",
      );
    } else {
      degradations.push({
        field: "contentBackend",
        from: "cos",
        to: "local",
        reason: "COS credentials missing (secretId / secretKey / bucket)",
        level: "info",
      });
      logger.info(
        `${TAG} contentBackend=cos requested but credentials missing — degrading to local fs`,
      );
      contentBackend = "local";
    }
  } else if (explicitContent === "local") {

View on GitHub (pinned to 3efcd317b8)

Solutions

  1. Provide the COS credentials via Shark COS config or cos.env in service mode (secretId, secretKey, bucket) and restart
  2. Verify the env file is actually mounted/loaded before resolveSkillConfig runs (check load order and path)
  3. Fix credential env var names/typos and confirm probe.hasCosCredentials becomes true (log it)
  4. If COS is not actually required, remove contentBackend:"cos" so config falls back to local with a recorded degradation

Example fix

// before: cos required but creds never loaded
const config = resolveSkillConfig({ contentBackend: "cos", strictMode: true });
// after: load creds first
import { loadCosEnv } from "./cos-env";
loadCosEnv("/etc/secrets/cos.env");
const config = resolveSkillConfig({ contentBackend: "cos", strictMode: true });
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync, readFileSync } from "fs";
function hasCosCreds(envPath = "/etc/secrets/cos.env"): boolean {
  const id = process.env.COS_SECRET_ID, key = process.env.COS_SECRET_KEY,
        bucket = process.env.COS_BUCKET;
  if (id && key && bucket) return true;
  if (existsSync(envPath)) {
    const txt = readFileSync(envPath, "utf8");
    return /COS_SECRET_ID=.+/.test(txt) && /COS_SECRET_KEY=.+/.test(txt) && /COS_BUCKET=.+/.test(txt);
  }
  return false;
}
if (wantCos && !hasCosCreds()) throw new Error("COS requested but credentials missing");

Type guard

function cosCredsPresent(c: { secretId?: string; secretKey?: string; bucket?: string }):
  c is { secretId: string; secretKey: string; bucket: string } {
  return Boolean(c.secretId && c.secretKey && c.bucket);
}

Try / catch

try {
  config = resolveSkillConfig({ contentBackend: "cos", strictMode: true });
} catch (e) {
  if (e instanceof SkillCoreError && e.code === "SKILL_COS_REQUIRED") {
    logger.error("COS backend requested but credentials missing; check cos.env / Shark config");
    process.exit(1); // or reconfigure to local backend
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling resolveSkillConfig (directly or via resolved()) with input.contentBackend = "cos" while the probed credential set (hasCosCredentials) is empty — secretId/secretKey/bucket not loaded from Shark COS config or cos.env in service mode, and strictMode is enabled.

Common situations: Deploying to an environment where cos.env is missing or not mounted; typos in env var names (COS_SECRET_ID etc.); credentials loaded after config resolution; copy-pasting a config with contentBackend:"cos" from another service that had the creds; CI runs without secret injection.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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