Mintplex-Labs/anything-llm · warning · Error

Type "${type}" is not a valid type to sync.

Error message

Type "${type}" is not a valid type to sync.

What it means

Thrown by the /ext/resync-source-document route dispatcher in collector/extensions/index.js:22 when the `type` field on the POST body does not match any key on RESYNC_METHODS. The handler checks `RESYNC_METHODS.hasOwnProperty(type)`, so only the exact string keys exported from collector/extensions/resync/index.js are accepted: link, youtube, confluence, github, gitlab, gitea, drupalwiki, paperless-ngx. The request is still answered HTTP 200 with success:false and the message in `reason`.

Source

Thrown at collector/extensions/index.js:22

  resolveRepoLoader,
  resolveRepoLoaderFunction,
} = require("../utils/extensions/RepoLoader");
const { reqBody } = require("../utils/http");
const { validURL, validateURL } = require("../utils/url");
const RESYNC_METHODS = require("./resync");
const { loadObsidianVault } = require("../utils/extensions/ObsidianVault");

function extensions(app) {
  if (!app) return;

  app.post(
    "/ext/resync-source-document",
    [verifyPayloadIntegrity, setDataSigner],
    async function (request, response) {
      try {
        const { type, options } = reqBody(request);
        if (!RESYNC_METHODS.hasOwnProperty(type))
          throw new Error(`Type "${type}" is not a valid type to sync.`);
        return await RESYNC_METHODS[type](options, response);
      } catch (e) {
        console.error(e);
        response.status(200).json({
          success: false,
          content: null,
          reason: e.message || "A processing error occurred.",
        });
      }
      return;
    }
  );

  app.post(
    "/ext/:repo_platform-repo",
    [verifyPayloadIntegrity, setDataSigner],
    async function (request, response) {
      try {

View on GitHub (pinned to 526360e320)

Solutions

  1. Send `type` as one of: "link", "youtube", "confluence", "github", "gitlab", "gitea", "drupalwiki", "paperless-ngx".
  2. Confirm the payload is JSON and that reqBody(request) actually parsed `type` (check Content-Type: application/json).
  3. If you need a new kind, register it in collector/extensions/resync/index.js by exporting a handler and re-deploy; otherwise pick an existing type.
  4. Read the returned `reason` field — it echoes the invalid type back so you can see exactly what the server received.

Example fix

// before
await fetch('/ext/resync-source-document', {
  method: 'POST',
  body: JSON.stringify({ type: 'github-file', options: { chunkSource } }),
});

// after — use the registered key
await fetch('/ext/resync-source-document', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ type: 'github', options: { chunkSource } }),
});
Defensive patterns

Strategy: validation

Validate before calling

const VALID_RESYNC_TYPES = [
  "link", "youtube", "confluence",
  "github", "gitlab", "gitea",
  "drupalwiki", "paperless-ngx",
];
function isValidResyncType(type) {
  return typeof type === "string" && VALID_RESYNC_TYPES.includes(type);
}
// before calling the API:
if (!isValidResyncType(body.type)) {
  throw new Error(`Unsupported resync type '${body.type}'. Valid: ${VALID_RESYNC_TYPES.join(", ")}`);
}

Type guard

/** @param {unknown} v */
function isResyncType(v) {
  return typeof v === "string" && Object.prototype.hasOwnProperty.call(
    { link:1, youtube:1, confluence:1, github:1, gitlab:1, gitea:1, drupalwiki:1, "paperless-ngx":1 },
    v,
  );
}

Try / catch

// server already returns 200 + success:false — treat the envelope as the error channel
const res = await fetch('/ext/resync-source-document', { method:'POST', body: JSON.stringify({ type, options }) });
const body = await res.json();
if (!body.success) throw new Error(`Resync failed: ${body.reason}`);

Prevention

When it happens

Trigger: POST /ext/resync-source-document with a body whose `type` is missing, undefined, null, an empty string, a typo like "github-file", or a value that was never a registered resync kind (e.g. "notion", "web"/*, "drive"). Anything that is not one of the eight RESYNC_METHODS keys triggers it.

Common situations: Frontend/client sends a stale `type` after an upgrade that renamed or removed a kind; payload omits `type`; a typo in integration code; calling the resync endpoint for a document type that the collector has no re-fetch path for.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/23e178e3c7a66254. Report an issue: GitHub.