mastra-ai/mastra · error

Sandbox provider "${options.sandbox.provider}" does not supp

Error message

Sandbox provider "${options.sandbox.provider}" does not support executeCommand, which is required for worker deploys.

What it means

attachWorkerDeployment reattaches to a persisted worker execution and needs to issue commands (e.g. to resolve the remote dir and inspect the process). Like runInSandbox, it requires the provider to implement executeCommand and fails fast with the provider name otherwise.

Source

Thrown at deployers/sandbox/src/worker.ts:138

        allowFailure: true,
        label: 'release worker artifact lock',
      });
    }
  }

  try {
    await installDependencies(sandbox, remoteDir, installHash ?? undefined, installCommand, options.installTimeoutMs);
  } catch (error) {
    throw workerPhaseError('install', error);
  }

  return createExecution(config, executionId, options.input);
}

/** Reattach to a persisted worker execution without its original launch configuration. */
export async function attachWorkerDeployment(options: AttachWorkerDeploymentOptions): Promise<SandboxWorkerExecution> {
  if (!options.sandbox.executeCommand) {
    throw new Error(
      `Sandbox provider "${options.sandbox.provider}" does not support executeCommand, which is required for worker deploys.`,
    );
  }
  validateExecutionId(options.executionId);
  if (
    options.terminationGraceMs !== undefined &&
    (!Number.isFinite(options.terminationGraceMs) || options.terminationGraceMs <= 0)
  ) {
    throw new Error('terminationGraceMs must be greater than zero.');
  }

  let remoteDir: string | undefined;
  const config: WorkerExecutionConfig = {
    sandbox: options.sandbox,
    resolveRemoteDir: async () => (remoteDir ??= await resolveRemoteDir(options.sandbox, options.remoteDir)),
    terminationGraceMs: options.terminationGraceMs ?? 5_000,
  };
  const info = await getInfoSafe(options.sandbox);

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Reconstruct the sandbox object with a working executeCommand implementation before reattaching.
  2. Switch to a provider that supports executeCommand.
  3. If only metadata is needed, use a provider API that fetches execution status instead of reattaching via commands.

Example fix

// before
await attachWorkerDeployment({ sandbox: storedSandbox, executionId });
// after
const sandbox = await createProviderSandbox({ id: storedSandbox.id }); // provider with executeCommand
await attachWorkerDeployment({ sandbox, executionId });
Defensive patterns

Strategy: validation

Validate before calling

if (typeof sandbox.executeCommand !== 'function') throw new Error('Cannot reattach: sandbox provider lacks executeCommand');

Type guard

function canAttach(s: WorkspaceSandbox): s is WorkspaceSandbox & Required<Pick<WorkspaceSandbox, 'executeCommand'>> {
  return typeof s.executeCommand === 'function';
}

Prevention

When it happens

Trigger: Calling attachWorkerDeployment({ sandbox, executionId, ... }) where options.sandbox.executeCommand is undefined.

Common situations: Reattaching after a process restart using a reconstructed/persisted sandbox descriptor that lacks the executeCommand closure; custom providers without exec support.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/ef2febaf23953424. Report an issue: GitHub.