{"record":{"id":"0aebf55da3743c95","repo":"windmill-labs/windmill","slug":"failed-to-resolve-local-relative-imports-for-previ","errorCode":null,"errorMessage":"Failed to resolve local relative imports for preview: ${msg}. Falling back to deployed script versions.","messagePattern":"Failed to resolve local relative imports for preview: (.+?)\\. Falling back to deployed script versions\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cli/src/commands/generate-metadata/generate-metadata.ts","lineNumber":188,"sourceCode":"\n    tree.propagateStaleness();\n    await uploadScripts(tree, workspace);\n    const refs = nodePath !== undefined\n      ? tree.getTempScriptRefs(nodePath)\n      : tree.getAllTempScriptRefs();\n    return refs && Object.keys(refs).length > 0 ? refs : undefined;\n  } catch (e) {\n    // Degrade gracefully (preview still runs against deployed versions) but do\n    // NOT mask the real error: only the missing-/raw_temp-endpoint case is an\n    // expected old-backend incompatibility — anything else is surfaced verbatim.\n    const msg = e instanceof Error ? e.message : String(e);\n    // Narrow: only the missing raw_temp endpoint is the expected old-backend\n    // signal. A bare 404/\"not found\" matches far too much (module/command/\n    // ENOENT \"not found\", \"Script X not found\", …) and would mislabel real\n    // bugs as a backend-too-old issue.\n    const isOldBackend = /raw_temp|raw_script_temp/i.test(msg);\n    if (!(opts as { silent?: boolean }).silent) {\n      log.warn(\n        colors.yellow(\n          isOldBackend\n            ? `Backend does not support local-import resolution for preview ` +\n                `(requires the /raw_temp endpoints); relative imports will use ` +\n                `deployed script versions.`\n            : `Failed to resolve local relative imports for preview: ${msg}. ` +\n                `Falling back to deployed script versions.`,\n        ),\n      );\n    }\n    return undefined;\n  }\n}\n\n/**\n * Categorize a flat list of file paths into scripts / flow folders / app\n * file paths. Used to derive item lists from a precomputed FS map (e.g.\n * sync pull's change-tracker output) without re-walking the filesystem.","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/generate-metadata/generate-metadata.ts#L170-L206","documentation":"`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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Upgrade the Windmill backend to a version supporting the `/raw_temp` endpoints.","If the message is not backend-related, check network/auth: run `wmill workspace show` and retry.","Push the locally modified imported scripts so deployed versions match: `wmill sync push`.","Set the `silent` option if this degradation is expected and the noise is unwanted in tooling."],"exampleFix":"// before: old backend silently ignores local import edits in preview\ndocker pull ghcr.io/windmill-labs/windmill:latest && docker compose up -d\n// after: current backend resolves local relative imports for preview","handlingStrategy":"fallback","validationCode":"// detect whether the backend supports raw_temp before relying on local import resolution\nconst res = await fetch(`${baseUrl}/api/w/${workspaceId}/scripts/raw_script_temp`, { method: 'HEAD', headers: { Authorization: token } });\nconst supportsLocalImports = res.status !== 404; // if false, push scripts instead","typeGuard":"null","tryCatchPattern":"try {\n  await previewScript(path);\n} catch (e: any) {\n  if (/raw_temp|deployed script versions/.test(e.message ?? '')) {\n    await wmill.syncPush(); // fall back to deployed content matching local\n    return previewScript(path);\n  }\n  throw e;\n}","preventionTips":["Keep the Windmill backend at a version with `/raw_temp` support.","Push imported scripts before previewing so the fallback is lossless.","Check backend health/auth before long dev sessions."],"tags":["cli","backend-version","relative-imports","fallback"],"backgroundTag":"backend-too-old","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}