{"record":{"id":"11457618c8735d7d","repo":"windmill-labs/windmill","slug":"no-workflow-entrypoint-found-wrap-your-main-fun","errorCode":null,"errorMessage":"No workflow() entrypoint found. Wrap your main function with workflow().","messagePattern":"No workflow\\(\\) entrypoint found\\. Wrap your main function with workflow\\(\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"backend/windmill-worker/src/bun_executor.rs","lineNumber":1934,"sourceCode":"    return [ {spread} ];\n}}\n\nBigInt.prototype.toJSON = function () {{\n    return this.toString();\n}};\n\n// Find the workflow entrypoint (export default)\nlet workflowFn = Main.default;\nif (!workflowFn || !workflowFn._is_workflow) {{\n    for (const key of Object.keys(Main)) {{\n        if (Main[key]?._is_workflow) {{\n            workflowFn = Main[key];\n            break;\n        }}\n    }}\n}}\nif (!workflowFn) {{\n    throw new Error(\"No workflow() entrypoint found. Wrap your main function with workflow().\");\n}}\n\nasync function run() {{\n    {dates}\n    {preprocessor}\n    const argsArr = {wac_spread};\n\n    const ctx = new WorkflowCtx(checkpoint);\n    setWorkflowCtx(ctx);\n\n    try {{\n        const result = await workflowFn(...argsArr);\n        setWorkflowCtx(null);\n        const failed = ctx._takePendingStepFailure?.();\n        if (failed) {{\n            throw failed.error;\n        }}\n        const swallowed = ctx._takePendingSuspend?.();","sourceCodeStart":1916,"sourceCodeEnd":1952,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-worker/src/bun_executor.rs#L1916-L1952","documentation":"For Windmill AI (WAC) workflow scripts in Bun, the generated wrapper scans the module's exports for the workflow entrypoint (typically a function wrapped by workflow()). If none of Main's exports qualify, it throws this error telling the author to wrap their main function with workflow().","triggerScenarios":"Running a Bun WAC-workflow script whose module has no export that the wrapper recognizes as the workflow entrypoint — e.g. the main function is defined but never wrapped with workflow(), or it isn't exported.","commonSituations":"Writing a plain script in a workflow-type script (missing the workflow() wrapper), renaming the wrapped function so the wrapper's export scan misses it, or exporting only helpers.","solutions":["Wrap the main function with workflow() and export it: `export const main = workflow(async (...) => {...})` per the WAC script template.","Verify the workflow-wrapped function is exported from the module.","If the script shouldn't be a workflow, change the script's kind instead of the code."],"exampleFix":"// before\nasync function main(a, b) { return a + b; }\n// after\nexport const main = workflow(async (a, b) => {\n  return a + b;\n});","handlingStrategy":"validation","validationCode":"// Lint check for WAC workflow scripts before deploy\nif (scriptKind === 'wac-workflow' && !/export\\s+const\\s+\\w+\\s*=\\s*workflow\\(/.test(source)) {\n  throw new Error('WAC workflow script must export a workflow()-wrapped entrypoint');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await windmill.runScript(path, hash_, args);\n} catch (e) {\n  if (e.message.includes('No workflow() entrypoint found')) {\n    console.error('Wrap main with workflow() and export it: export const main = workflow(async (...) => {...})');\n  }\n  throw e;\n}","preventionTips":["Start WAC workflow scripts from the official template that already wraps main.","Never rename the workflow-wrapped export away from what the wrapper scans for.","Add a CI lint asserting the workflow() wrapper exists for workflow-kind scripts."],"tags":["bun","wac","workflow","missing-entrypoint"],"backgroundTag":"missing-entrypoint-function","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"}