mastra-ai/mastra · error · Error

Extractor name "${name}" must produce a non-empty slug.

Error message

Extractor name "${name}" must produce a non-empty slug.

What it means

Extractor names are slugified into identifiers used in paths/metadata. If the slugification of an extractor's name yields an empty string — typically because the name contains no slug-able characters — assertValidSlug throws this error.

Source

Thrown at packages/memory/src/processors/observational-memory/extractor.ts:109

      normalized += char;
      previousWasSeparator = false;
      continue;
    }
    if (char === "'" || char === '"' || char === '`') {
      continue;
    }
    if (!previousWasSeparator && normalized.length > 0) {
      normalized += '-';
      previousWasSeparator = true;
    }
  }

  return normalized.endsWith('-') ? normalized.slice(0, -1) : normalized;
}

function assertValidSlug(slug: string, name: string): void {
  if (!slug) {
    throw new Error(`Extractor name "${name}" must produce a non-empty slug.`);
  }
  const first = slug.charCodeAt(0);
  const last = slug.charCodeAt(slug.length - 1);
  const startsWithLetter = first >= 97 && first <= 122;
  const endsWithLetterOrNumber = (last >= 97 && last <= 122) || (last >= 48 && last <= 57);
  const hasOnlySlugCharacters = [...slug].every(char => {
    const code = char.charCodeAt(0);
    return (code >= 97 && code <= 122) || (code >= 48 && code <= 57) || char === '-';
  });
  if (!startsWithLetter || !endsWithLetterOrNumber || !hasOnlySlugCharacters) {
    throw new Error(`Extractor name "${name}" produced invalid slug "${slug}".`);
  }
}

export class Extractor<T = unknown> {
  readonly name: string;
  readonly slug: string;
  readonly instructions: string;

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Give the extractor an ASCII alphanumeric name (e.g. 'user-preferences')
  2. If the source name is derived from user input, provide an explicit fallback slug-able name when slugification would empty it
  3. Trim/replace non-alphanumeric characters before constructing the Extractor

Example fix

// before
new Extractor({ name: '!!!', instructions: '...' });

// after
new Extractor({ name: 'key-facts', instructions: '...' });
Defensive patterns

Strategy: validation

Validate before calling

const slugify = (n: string) => n.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
if (!slugify(name)) throw new Error(`Extractor name "${name}" must contain slug-able characters`);

Try / catch

try {
  new Extractor({ name: userLabel, instructions });
} catch (err) {
  if (err instanceof Error && err.message.includes('non-empty slug')) {
    return new Extractor({ name: 'extractor-' + Date.now().toString(36), instructions });
  }
  throw err;
}

Prevention

When it happens

Trigger: Constructing an Extractor (or registering one in validateExtractorList) with a name consisting solely of characters stripped by slugification (e.g. "!!!", " ", "---" or non-ASCII-only names that normalize to nothing).

Common situations: Auto-generating extractor names from user labels/emojis; i18n names in scripts that slugify to empty; building extractors programmatically from config where name defaults to punctuation.

Related errors


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