{"record":{"id":"a36be0d0c06b538e","repo":"windmill-labs/windmill","slug":"draft-script-modulevalue-path-is-missing-cont","errorCode":null,"errorMessage":"Draft script \"${moduleValue.path}\" is missing content or language.","messagePattern":"Draft script \"(.+?)\" is missing content or language\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/global/core.ts","lineNumber":5340,"sourceCode":"\t)\n}\n\nfunction normalizeTestRunArgs(args: Record<string, any> | null | undefined): Record<string, any> {\n\treturn args ?? {}\n}\n\nfunction flowDraftValueForPreview(flowDraft: FlowDraftValue): FlowValue {\n\treturn flowDraftAsEditableInput(flowDraft).value\n}\n\nasync function loadScriptForFlowStep(\n\tmoduleValue: { path: string; hash?: string },\n\tworkspace: string\n): Promise<{ content: string; language: ScriptLang }> {\n\tconst draft = await getGlobalDraft(workspace, 'script', moduleValue.path)\n\tif (draft) {\n\t\tif (typeof draft.value !== 'string' || !draft.language) {\n\t\t\tthrow new Error(`Draft script \"${moduleValue.path}\" is missing content or language.`)\n\t\t}\n\t\treturn { content: draft.value, language: draft.language }\n\t}\n\n\tconst script = moduleValue.hash\n\t\t? await ScriptService.getScriptByHash({ workspace, hash: moduleValue.hash })\n\t\t: await ScriptService.getScriptByPath({ workspace, path: moduleValue.path })\n\treturn { content: script.content, language: script.language }\n}\n\nasync function loadDraftFlowPreviewValue(\n\tpath: string,\n\tworkspace: string\n): Promise<FlowValue | undefined> {\n\tif (!(await getGlobalDraft(workspace, 'flow', path))) {\n\t\treturn undefined\n\t}\n\tconst nestedFlow = await loadFlowDraftValue(path, workspace)","sourceCodeStart":5322,"sourceCodeEnd":5358,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/global/core.ts#L5322-L5358","documentation":"When resolving a flow module's script content, a draft script for the module's path is checked first. If the draft exists but has no string content or no language, the tool throws instead of silently falling back, because the draft — not the deployed script — is the source of truth the model is editing. Deployed scripts are only read when no draft exists.","triggerScenarios":"getGlobalDraft(workspace, 'script', moduleValue.path) returns a draft with non-string value or missing language while loading a module's script for a flow inline-script operation.","commonSituations":"A partial write_script draft for the module's script path was left by an interrupted earlier call; the draft holds only a summary; the module points at a script path whose draft was created but never filled.","solutions":["Complete the draft with write_script (content + language) for that path, then retry.","Delete the incomplete draft so resolution falls back to the deployed script (by hash or path).","Inline the script content into the flow module if it was meant to be a rawscript."],"exampleFix":"// before\nwriteScript({ path: 'u/user/helper', summary: 'wip' }) // draft without content\n// after\nwriteScript({ path: 'u/user/helper', content: 'export function main(){}', language: 'bun' })","handlingStrategy":"type-guard","validationCode":"const draft = await getGlobalDraft(workspace, 'script', moduleValue.path)\nif (draft && (typeof draft.value !== 'string' || !draft.language)) {\n  await deleteGlobalDraft(workspace, 'script', moduleValue.path)\n}","typeGuard":"function hasContentAndLang(d: unknown): d is { value: string; language: ScriptLang } {\n  const x = d as any\n  return !!x && typeof x.value === 'string' && typeof x.language === 'string'\n}","tryCatchPattern":"try {\n  return await loadModuleScript(moduleValue)\n} catch (e) {\n  if (String(e.message).includes('missing content or language')) {\n    return ScriptService.getScriptByHash({ workspace, hash: moduleValue.hash! })\n  }\n  throw e\n}","preventionTips":["Complete script drafts (content + language) before running flow edit sessions.","Delete abandoned partial drafts for module script paths.","Prefer inlining module code so resolution does not depend on separate script drafts."],"tags":["draft-state","scripts","flows"],"backgroundTag":"incomplete-draft-state","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"}