mastra-ai/mastra · error
Summaries must be one of 'self', 'prev', 'next'
Error message
Summaries must be one of 'self', 'prev', 'next'
What it means
The SummaryExtractor constructor validates the `summaries` option array: at least one entry must be one of 'self', 'prev', or 'next'. An empty array or an array containing only unknown values is rejected because the extractor would have nothing to summarize.
Source
Thrown at packages/rag/src/document/extractors/summary.ts:35
/**
* Summarize an array of nodes using a custom LLM.
*
* @param nodes Array of node-like objects
* @param options Summary extraction options
* @returns Array of summary results
*/
export class SummaryExtractor extends BaseExtractor {
private llm: MastraLanguageModel | MastraLegacyLanguageModel;
summaries: string[];
promptTemplate: SummaryPrompt;
private selfSummary: boolean;
private prevSummary: boolean;
private nextSummary: boolean;
constructor(options?: SummaryExtractArgs) {
const summaries = options?.summaries ?? ['self'];
if (summaries && !summaries.some(s => ['self', 'prev', 'next'].includes(s)))
throw new Error("Summaries must be one of 'self', 'prev', 'next'");
super();
this.llm = options?.llm ?? baseLLM;
this.summaries = summaries;
this.promptTemplate = options?.promptTemplate
? new PromptTemplate({
templateVars: ['context'],
template: options.promptTemplate,
})
: defaultSummaryPrompt;
this.selfSummary = summaries?.includes('self') ?? false;
this.prevSummary = summaries?.includes('prev') ?? false;
this.nextSummary = summaries?.includes('next') ?? false;
}
/**View on GitHub (pinned to 75dd419e61)
Solutions
- Use only 'self', 'prev', and/or 'next' in the summaries array, e.g. { summaries: ['self', 'prev'] }.
- Fix casing/typos — the values are case-sensitive lowercase strings.
- Omit the option entirely to default to ['self'].
Example fix
// before
new SummaryExtractor({ summaries: ['previous'] });
// after
new SummaryExtractor({ summaries: ['prev', 'next'] }); Defensive patterns
Strategy: validation
Validate before calling
const VALID = ['self', 'prev', 'next'] as const;
type SummaryMode = typeof VALID[number];
const summaries: SummaryMode[] = (config.summaries ?? ['self']).filter((s): s is SummaryMode => (VALID as readonly string[]).includes(s));
if (summaries.length === 0) throw new Error('summaries must contain at least one of self|prev|next'); Type guard
const isSummaryMode = (s: unknown): s is 'self' | 'prev' | 'next' => s === 'self' || s === 'prev' || s === 'next';
Try / catch
try {
return new SummaryExtractor({ summaries });
} catch (e) {
if (e instanceof Error && e.message.includes("Summaries must be one of")) {
return new SummaryExtractor(); // defaults to ['self']
}
throw e;
} Prevention
- Type the option as a union literal type so typos fail at compile time.
- Never accept free strings from config without whitelist filtering.
- Rely on the default ['self'] when unsure.
When it happens
Trigger: new SummaryExtractor({ summaries: [] }) or new SummaryExtractor({ summaries: ['sibling'] }) — empty array or entries outside the allowed set.
Common situations: Typos in mode names ('Self', 'previous', 'curr'), empty config arrays read from JSON/YAML, or passing values copied from another library's summary extractor.
Understand the failure class
Background: "Invalid configuration value" and "Unsupported/Unknown setting value" errors: why libraries reject your config strings, numbers, and types — this error's family across 30 libraries.
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/a8d0051f489234b9.
Report an issue: GitHub.