no-workflow-call-without-container - ESLint plugin rules

This rule requires a workflow to be invoked with the Medusa container, as in workflow(container).run({ input }).

Severity#

warn. This rule is enabled in the strict preset.

By default, Medusa projects use the recommended preset, which doesn't enable this rule. To use it, switch to the strict preset.

What it Targets#

This rule targets workflow execution calls anywhere in your project. It reports invoking a workflow with no arguments or accessing its .run method directly, without passing the container.

The following code is reported by the rule:

src/api/store/custom/route.ts
1import { myWorkflow } from "../../../workflows/my-workflow"2
3async function handler() {4  await myWorkflow().run({ input: {} })5}

Instead, pass the container when invoking the workflow:

src/api/store/custom/route.ts
1import { myWorkflow } from "../../../workflows/my-workflow"2
3async function handler(container) {4  await myWorkflow(container).run({ input: {} })5}

Why it's Important#

A workflow resolves its steps' dependencies from the Medusa container. Invoking the workflow without the container, or calling .run directly, bypasses container resolution and the workflow fails to execute correctly.

Learn more in the Workflows documentation.

Fixable#

This rule isn't auto-fixable.

Turn it Off#

To turn off this rule, set it to off in your ESLint configuration:

eslint.config.ts
1import { defineConfig } from "eslint/config"2import medusa from "@medusajs/eslint-plugin"3
4export default defineConfig([5  ...medusa.configs.strict,6  {7    rules: {8      "@medusajs/no-workflow-call-without-container": "off",9    },10  },11])

Or disable it for a single line using an inline comment:

Code
1// eslint-disable-next-line @medusajs/no-workflow-call-without-container2await myWorkflow().run({ input: {} })
Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵