medusajs/medusa · error · Error
--paths must be a directory - ${additionalPath}
Error message
--paths must be a directory - ${additionalPath} What it means
The Redis engine's cancel() requires the workflow id (string or object with getName()) to locate the flow definition. A falsy id throws a plain Error 'Workflow ID is required' before anything is cancelled.
Source
Thrown at packages/cli/oas/medusa-oas-cli/src/command-oas.ts:84
export async function execute(cliParams: OptionValues) {
/**
* Process CLI options
*/
const dryRun = !!cliParams.dryRun
const force = !!cliParams.force
const v2 = !!cliParams.v2
const local = !!cliParams.local
const apiType: ApiType = cliParams.type
const outDir = path.resolve(cliParams.outDir)
const additionalPaths = (cliParams.paths ?? []).map((additionalPath) =>
path.resolve(additionalPath)
)
for (const additionalPath of additionalPaths) {
if (!(await isDirectory(additionalPath))) {
throw new Error(`--paths must be a directory - ${additionalPath}`)
}
}
const baseFile = cliParams.base ? path.resolve(cliParams.base) : undefined
if (baseFile) {
if (!(await isFile(cliParams.base))) {
throw new Error(`--base must be a file - ${baseFile}`)
}
}
/**
* Command execution
*/
if (!dryRun) {
await mkdir(outDir, { recursive: true })
}
let oas: OpenAPIObjectView on GitHub (pinned to 5e06e544a2)
Solutions
- Validate and pass a real workflowId when calling cancel
- Persist workflowId alongside transactionId when the run starts
- Return 400 early in API layers when workflowId is missing
Example fix
// before await engine.cancel(body.wf, body.tx) // after if (!body.wf || !body.tx) throw new MedusaError(MedusaError.Types.INVALID_DATA, 'workflowId and transactionId required') await engine.cancel(body.wf, body.tx)
Defensive patterns
Strategy: validation
Validate before calling
if (!workflowId || !transactionId) throw new Error('workflowId and transactionId are required to cancel')
await engine.cancel(workflowId, transactionId) Type guard
const isCancelArgs = (wf: unknown, tx: unknown): wf is string => typeof wf === 'string' && wf.length > 0 && typeof tx === 'string' && tx.length > 0
Try / catch
catch (e) { if (e.message === 'Workflow ID is required') return badRequest('workflowId missing'); throw e } Prevention
- Persist workflowId+transactionId pairs when runs start
- Validate cancel requests at the API boundary
When it happens
Trigger: Calling cancel(undefined | '', transactionId) — e.g. destructuring workflowId from a job payload where the field is absent.
Common situations: Cancelling workflows from queue messages/events where the workflowId field was not propagated; API endpoints that accept optional workflow ids and pass them through unchecked.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- --base must be a file - ${baseFile}
- Key ${key} already exists in app metadata
- insufficient_inventory
- not_found
- --config file must be of type .json or .yaml - ${configFileC
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/0fd86b871c9fea41.
Report an issue: GitHub.