windmill-labs/windmill · warning

Failed to resolve local relative imports for preview: ${msg}

Error message

Failed to resolve local relative imports for preview: ${msg}. Falling back to deployed script versions.

What it means

`buildPreviewTempScriptRefs` resolves a script's local relative imports for preview by uploading temp copies to `/raw_temp` backend endpoints. On failure it degrades gracefully: if the message matches `raw_temp` it explains the backend predates those endpoints; otherwise it reports the generic failure and falls back to deployed script versions for imports.

Source

Thrown at cli/src/commands/generate-metadata/generate-metadata.ts:188

    tree.propagateStaleness();
    await uploadScripts(tree, workspace);
    const refs = nodePath !== undefined
      ? tree.getTempScriptRefs(nodePath)
      : tree.getAllTempScriptRefs();
    return refs && Object.keys(refs).length > 0 ? refs : undefined;
  } catch (e) {
    // Degrade gracefully (preview still runs against deployed versions) but do
    // NOT mask the real error: only the missing-/raw_temp-endpoint case is an
    // expected old-backend incompatibility — anything else is surfaced verbatim.
    const msg = e instanceof Error ? e.message : String(e);
    // Narrow: only the missing raw_temp endpoint is the expected old-backend
    // signal. A bare 404/"not found" matches far too much (module/command/
    // ENOENT "not found", "Script X not found", …) and would mislabel real
    // bugs as a backend-too-old issue.
    const isOldBackend = /raw_temp|raw_script_temp/i.test(msg);
    if (!(opts as { silent?: boolean }).silent) {
      log.warn(
        colors.yellow(
          isOldBackend
            ? `Backend does not support local-import resolution for preview ` +
                `(requires the /raw_temp endpoints); relative imports will use ` +
                `deployed script versions.`
            : `Failed to resolve local relative imports for preview: ${msg}. ` +
                `Falling back to deployed script versions.`,
        ),
      );
    }
    return undefined;
  }
}

/**
 * Categorize a flat list of file paths into scripts / flow folders / app
 * file paths. Used to derive item lists from a precomputed FS map (e.g.
 * sync pull's change-tracker output) without re-walking the filesystem.

View on GitHub (pinned to e474e8803c)

Solutions

  1. Upgrade the Windmill backend to a version supporting the `/raw_temp` endpoints.
  2. If the message is not backend-related, check network/auth: run `wmill workspace show` and retry.
  3. Push the locally modified imported scripts so deployed versions match: `wmill sync push`.
  4. Set the `silent` option if this degradation is expected and the noise is unwanted in tooling.

Example fix

// before: old backend silently ignores local import edits in preview
docker pull ghcr.io/windmill-labs/windmill:latest && docker compose up -d
// after: current backend resolves local relative imports for preview
Defensive patterns

Strategy: fallback

Validate before calling

// detect whether the backend supports raw_temp before relying on local import resolution
const res = await fetch(`${baseUrl}/api/w/${workspaceId}/scripts/raw_script_temp`, { method: 'HEAD', headers: { Authorization: token } });
const supportsLocalImports = res.status !== 404; // if false, push scripts instead

Type guard

null

Try / catch

try {
  await previewScript(path);
} catch (e: any) {
  if (/raw_temp|deployed script versions/.test(e.message ?? '')) {
    await wmill.syncPush(); // fall back to deployed content matching local
    return previewScript(path);
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `wmill dev`, `wmill flow preview`, or `wmill script run/preview` on a script with relative imports when: the backend is too old to expose `/raw_temp` (matched by the raw_temp/raw_script_temp regex), or the upload/resolve step errors (network failure, auth error, filesystem error reading the imported file).

Common situations: Self-hosted Windmill instance not upgraded in a while (no raw_temp endpoints); corporate proxy blocking POST uploads; imported file deleted or unreadable locally; expired workspace token mid-session.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/0aebf55da3743c95. Report an issue: GitHub.