windmill-labs/windmill · error · Error

Module "${args.module_id}" is not an inline rawscript in flo

Error message

Module "${args.module_id}" is not an inline rawscript in flow "${args.path}". Use patch_flow_json or write_flow for structural changes.

What it means

The write-inline-script tool can only replace code of an existing inline rawscript module. If the inline-script session built from the flow draft has no entry for the given module_id, the tool refuses — it cannot create new modules — and points to patch_flow_json or write_flow for structural changes.

Source

Thrown at frontend/src/lib/components/copilot/chat/global/core.ts:5309

	toolCallbacks.setToolStatus(toolId, {
		content: `Read inline script for "${args.module_id}"`
	})
	return content
}

async function setFlowModuleCode(
	args: { path: string; module_id: string; code: string },
	ctx: WriteDraftCtx
): Promise<string> {
	const { workspace, toolId, toolCallbacks } = ctx
	toolCallbacks.setToolStatus(toolId, {
		content: `Updating inline script for module "${args.module_id}" in flow "${args.path}"...`
	})
	const base = await loadFlowDraftValue(args.path, workspace)
	const session = createInlineScriptSession()
	const editable = buildEditableFlowJson(flowDraftAsEditableInput(base.flow), session)
	if (!session.has(args.module_id)) {
		throw new Error(
			`Module "${args.module_id}" is not an inline rawscript in flow "${args.path}". Use patch_flow_json or write_flow for structural changes.`
		)
	}
	session.set(args.module_id, args.code)
	const newFlowValue = applyEditableFlowJsonToFlow(base.flow.value, editable, session)
	return writeFlowDraft(
		{
			path: args.path,
			summary: base.summary,
			flow: { ...base.flow, value: newFlowValue }
		},
		ctx
	)
}

function normalizeTestRunArgs(args: Record<string, any> | null | undefined): Record<string, any> {
	return args ?? {}
}

View on GitHub (pinned to e474e8803c)

Solutions

  1. Use patch_flow_json to add the module structurally first, then update its code inline.
  2. Use write_flow to rewrite the flow including the new/changed module.
  3. If the module is a path runnable, edit the referenced script instead of the flow module.

Example fix

// before
writeInlineScript({ path: 'f/x', module_id: 'new_step', code: '...' }) // module does not exist
// after
patchFlowJson({ path: 'f/x', addModule: { id: 'new_step', type: 'rawscript', ... } })
writeInlineScript({ path: 'f/x', module_id: 'new_step', code: '...' })
Defensive patterns

Strategy: validation

Validate before calling

const session = peekInlineScriptSession(args.path) // or inspect flow JSON
if (!session?.has(args.module_id)) {
  await patchFlowJson({ path: args.path, addModule: { id: args.module_id, type: 'rawscript' } })
}

Type guard

function canEditInline(flow: FlowValue, moduleId: string): boolean {
  const m = findModule(flow, moduleId)
  return !!m && m.type === 'rawscript' && typeof (m.value as any)?.content === 'string'
}

Try / catch

try {
  await writeInlineScript(args)
} catch (e) {
  if (e.message.includes('not an inline rawscript')) {
    await writeFlow({ ...flowIncluding(args.module_id) }) // structural change first
  } else throw e
}

Prevention

When it happens

Trigger: Calling the update-inline-script flow tool with args.module_id where session.has(module_id) is false: the id is not an inline rawscript in flow args.path.

Common situations: Trying to 'add' a step by writing code for a not-yet-existing module id; targeting a path runnable, branch or loop node; a typo'd or stale module id after the flow was restructured.

Related errors


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