{"record":{"id":"7815e7c281282992","repo":"windmill-labs/windmill","slug":"module-value-is-undefined-for-module-module-id","errorCode":null,"errorMessage":"Module value is undefined for module ${module.id}","messagePattern":"Module value is undefined for module (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/windmill-utils-internal/src/inline-scripts/replacer.ts","lineNumber":86,"sourceCode":"export async function replaceInlineScripts(\n    modules: FlowModule[],\n    fileReader: (path: string) => Promise<string>,\n    logger: {\n      info: (message: string) => void,\n      error: (message: string) => void,\n    } = {\n      info: () => {},\n      error: () => {},\n    },\n    localPath: string,\n    separator: string = \"/\",\n    removeLocks?: string[],\n    missingFiles?: string[],\n  ): Promise<string[]> {\n    const missing = missingFiles ?? [];\n    await Promise.all(modules.map(async (module) => {\n      if (!module.value) {\n        throw new Error(`Module value is undefined for module ${module.id}`);\n      }\n\n      if (module.value.type === \"rawscript\") {\n        await replaceRawscriptInline(\n          module.id,\n          module.value,\n          fileReader,\n          logger,\n          separator,\n          removeLocks,\n          missing\n        );\n      } else if (module.value.type === \"forloopflow\" || module.value.type === \"whileloopflow\") {\n        await replaceInlineScripts(module.value.modules, fileReader, logger, localPath, separator, removeLocks, missing);\n      } else if (module.value.type === \"branchall\") {\n        await Promise.all(module.value.branches.map(async (branch) => {\n          await replaceInlineScripts(branch.modules, fileReader, logger, localPath, separator, removeLocks, missing);\n        }));","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/windmill-utils-internal/src/inline-scripts/replacer.ts#L68-L104","documentation":"replaceInlineScripts walks a flow's module tree and, for each module, inlines file contents back into the flow definition before pushing. If `module.value` is undefined — the module has no value payload at all — it throws `Module value is undefined for module <id>`. A well-formed flow module (rawscript, flow, etc.) always carries a value, so this indicates a malformed flow definition or an incomplete/incorrectly-shaped parsed module.","triggerScenarios":"replaceInlineScripts called on modules from a flow YAML where a module entry lacks its `value` key (e.g. hand-edited flow file, a module type the parser did not resolve, or a flow/suspend branch whose value was stripped by tooling).","commonSituations":"Manually editing a flow YAML and deleting or renaming the `value` block; a merge conflict resolved by dropping a module's value; generating flows programmatically with a missing value for some module id; version skew where an old flow format lacks value on a new module type.","solutions":["Open the flow YAML at the failing module `id` and add back its `value` block (type + content/inputs)","Restore the flow file from git (`git checkout -- <file>`) to recover the missing value","Re-pull the flow with `wmill sync pull` so the definition is rebuilt from the backend","If generating flows in code, ensure every module gets a non-null `value` before calling replaceInlineScripts"],"exampleFix":"// before\n{\n  \"id\": \"a\",\n  \"value\": undefined // module missing value\n}\n\n// after\n{\n  \"id\": \"a\",\n  \"value\": { \"type\": \"rawscript\", \"content\": \"...\", \"language\": \"python3\" }\n}","handlingStrategy":"type-guard","validationCode":"interface FlowModuleLike { id: string; value?: unknown }\nfunction allModulesHaveValue(modules: FlowModuleLike[]): boolean {\n  return modules.every(m => m.value != null);\n}\nif (!allModulesHaveValue(flow.value.modules)) throw new Error('Flow has modules without value');","typeGuard":"function hasModuleValue(m: { id: string; value?: unknown }): m is { id: string; value: object } {\n  return m.value != null && typeof m.value === 'object';\n}","tryCatchPattern":"try {\n  await replaceInlineScripts(flow.value.modules, ...);\n} catch (e) {\n  if ((e as Error).message.startsWith('Module value is undefined')) {\n    console.error('Flow definition malformed — restore from git or re-pull');\n  } else throw e;\n}","preventionTips":["Validate flow YAML shape (every module has id + value) before pushing","Never resolve merge conflicts by deleting a module's value block","Type generated flow objects so a missing value is a compile-time error"],"tags":["inline-scripts","flow","validation"],"backgroundTag":"malformed-flow-module","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"}