mastra-ai/mastra · error
Language ${language} is not supported! Please choose from ${
Error message
Language ${language} is not supported! Please choose from ${Object.values(Language)} What it means
CharacterTextSplitter.getSeparatorsForLanguage maps a Language enum value to markdown-aware separator strings. If the language isn't in the switch's cases, the default branch throws listing all supported languages.
Source
Thrown at packages/rag/src/document/transformers/character.ts:641
];
case Language.PROTO:
return [
'\nsyntax ',
'\npackage ',
'\nimport ',
'\nmessage ',
'\nservice ',
'\nenum ',
'\nrpc ',
'\n\n',
'\n',
' ',
'',
];
case Language.RST:
return ['\n=+\n', '\n-+\n', '\n\\*+\n', '\n\\.\\. ', '\n\n', '\n', ' ', ''];
default:
throw new Error(`Language ${language} is not supported! Please choose from ${Object.values(Language)}`);
}
}
}
View on GitHub (pinned to 75dd419e61)
Solutions
- Use a supported Language enum member (e.g. Language.MARKDOWN, Language.RST) instead of a raw/typo'd string.
- Check the list in the thrown message (Object.values(Language)) and pick from it.
- If you need a language that isn't supported yet, pass plain separators/defaults or fall back to CharacterTextSplitter without markdown-awareness.
Example fix
// before
new CharacterTextSplitter({ separator: '
', language: 'md' as Language });
// after
import { Language } from '@mastra/rag';
new CharacterTextSplitter({ separator: '
', language: Language.MARKDOWN }); Defensive patterns
Strategy: validation
Validate before calling
import { Language } from '@mastra/rag';
const lang: Language | undefined = Object.values(Language).find(v => v === config.language);
if (!lang) throw new Error(`Unsupported language: ${config.language}`); Type guard
const isSupportedLanguage = (v: unknown): v is Language => typeof v === 'string' && (Object.values(Language) as string[]).includes(v);
Try / catch
try {
return splitter.splitText(text);
} catch (e) {
if (e instanceof Error && e.message.includes('is not supported')) {
return fallbackSplitter.splitText(text);
}
throw e;
} Prevention
- Always use Language enum members, never raw strings.
- Validate config language values against Object.values(Language) at startup.
- After upgrading @mastra/rag, re-check that your chosen language still has a separator table.
When it happens
Trigger: splitText/splitMarkdown with a Language value that has no separator table (e.g. a Language added to the enum but not handled in getSeparatorsForLanguage), or a cast string like 'xyz' as Language passed to the constructor.
Common situations: Passing a raw string from config as Language without validation, upgrading @mastra/rag and using a newly added Language while on a stale splitter path, or typo'd language names.
Related errors
- HTML chunking requires either headers or sections to be spec
- JSON chunking requires maxSize to be specified
- Sentence chunking requires maxSize to be specified
- Keywords must be greater than 0
- Questions must be greater than 0
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/7e216bc123372225.
Report an issue: GitHub.