mastra-ai/mastra · error · MastraError

DEPLOYER_INVALID_PNPM_BUILD_APPROVAL_CONFIG

DEPLOYER_INVALID_PNPM_BUILD_APPROVAL_CONFIG

Error message

Invalid pnpm ${key} configuration

What it means

validatePnpmBuildApprovals parses pnpm-workspace.yaml blocks for allowBuilds or onlyBuiltDependencies keys and throws DEPLOYER_INVALID_PNPM_BUILD_APPROVAL_CONFIG if the YAML block cannot be parsed or the key's value is not in the expected shape. Categorized as USER because the input is project configuration. Details include the offending key.

Source

Thrown at packages/deployer/src/services/deps.ts:72

    .map(specifier => specifier.trim())
    .filter(Boolean)
    .map(specifier => {
      if (specifier.startsWith('@')) {
        const versionSeparator = specifier.indexOf('@', 1);
        return versionSeparator === -1 ? specifier : specifier.slice(0, versionSeparator);
      }
      return specifier.split('@', 1)[0]!;
    });
}

function validatePnpmBuildApprovals(key: string, block: string): void {
  if (key !== 'allowBuilds' && key !== 'onlyBuiltDependencies') return;

  let value: unknown;
  try {
    value = (parse(block) as Record<string, unknown>)[key];
  } catch (error) {
    throw new MastraError(
      {
        id: 'DEPLOYER_INVALID_PNPM_BUILD_APPROVAL_CONFIG',
        domain: ErrorDomain.DEPLOYER,
        category: ErrorCategory.USER,
        details: { key },
        text: `Invalid pnpm ${key} configuration`,
      },
      error,
    );
  }

  const invalidEntries =
    key === 'allowBuilds'
      ? value && typeof value === 'object' && !Array.isArray(value)
        ? Object.entries(value).filter(
            ([dependency, approval]) => dependency.trim().length === 0 || typeof approval !== 'boolean',
          )
        : [[key, value]]

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Open pnpm-workspace.yaml and fix the allowBuilds/onlyBuiltDependencies value to the correct YAML type (list of package names).
  2. Validate the file with `pnpm install` — pnpm will also report YAML parse errors.
  3. Run `pnpm approve-builds` to generate a correctly-shaped configuration.

Example fix

# before
onlyBuiltDependencies: sharp
# after
onlyBuiltDependencies:
  - sharp
Defensive patterns

Strategy: validation

Validate before calling

const yaml = require('yaml');
const ws = yaml.parse(require('fs').readFileSync('pnpm-workspace.yaml', 'utf8'));
for (const key of ['allowBuilds', 'onlyBuiltDependencies']) {
  if (key in ws && !Array.isArray(ws[key])) {
    throw new Error(`pnpm-workspace.yaml: ${key} must be a YAML list of package names`);
  }
}

Try / catch

try {
  await deploy();
} catch (e) {
  if (e?.id === 'DEPLOYER_INVALID_PNPM_BUILD_APPROVAL_CONFIG') {
    console.error(`Fix pnpm-workspace.yaml key '${e.details?.key}': value must be a list of package names.`);
  }
  throw e;
}

Prevention

When it happens

Trigger: copyPnpmWorkspaceSettings encounters a pnpm-workspace.yaml whose allowBuilds/onlyBuiltDependencies value is malformed — e.g. onlyBuiltDependencies is a string instead of an array, or the YAML around it fails to parse.

Common situations: Hand-editing pnpm-workspace.yaml with wrong indentation; writing onlyBuiltDependencies: eslint instead of a YAML list; mixing pnpm v9 (onlyBuiltDependencies) and v10 (allowBuilds) syntax incorrectly.

Related errors


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