paperclipai/paperclip · error · PluginSandboxError

Unable to resolve module import at path '${candidatePath}'

Error message

Unable to resolve module import at path '${candidatePath}'

What it means

Resolution guard in resolveModulePathSync: none of the candidate paths plus known suffixes (.js, /index.js, etc.) exist on disk. The imported file is missing or the specifier is wrong; the unresolvable import path is at fault.

Source

Thrown at server/src/services/plugin-runtime-sandbox.ts:186

    return normalizedExports;
  };

  const entryExports = loadModuleSync(entrypointPath);

  return {
    namespace: { ...entryExports },
  };
}

function resolveModulePathSync(candidatePath: string): string {
  for (const suffix of MODULE_PATH_SUFFIXES) {
    const fullPath = `${candidatePath}${suffix}`;
    if (existsSync(fullPath)) {
      return fullPath;
    }
  }

  throw new PluginSandboxError(`Unable to resolve module import at path '${candidatePath}'`);
}

/**
 * True when `targetPath` is inside `rootPath` (or equals rootPath), false otherwise.
 * Uses `path.relative` so sibling-prefix paths (e.g. `/root-a` vs `/root`) cannot bypass checks.
 */
function isWithinRoot(targetPath: string, rootPath: string): boolean {
  const relative = path.relative(rootPath, targetPath);
  return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
}

function readModuleSourceSync(modulePath: string): string {
  try {
    return readFileSync(modulePath, "utf8");
  } catch (error) {
    throw new PluginSandboxError(
      `Failed to read sandbox module '${modulePath}': ${error instanceof Error ? error.message : String(error)}`,
    );

View on GitHub (pinned to 120ae5428f)

Solutions

  1. Fix the import path: the file does not exist at the resolved candidate. Check the path, extension, and that the file ships with the plugin build.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/src/services/plugin-runtime-sandbox.ts:186 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18). Data as JSON: /api/errors/3b41904b58a45c1a. Report an issue: GitHub.