n8n-io/n8n · error · NodeOperationError
No sentiment categories provided
Error message
No sentiment categories provided
What it means
Thrown by the Sentiment Analysis node when the 'options.categories' parameter, after splitting on commas and filtering empties, yields zero categories. The node needs at least one sentiment label to classify against, so an empty list halts execution.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/chains/SentimentAnalysis/SentimentAnalysis.node.ts:338
}
}
} else {
// Sequential Processing
for (let i = 0; i < items.length; i++) {
try {
const sentimentCategories = this.getNodeParameter(
'options.categories',
i,
DEFAULT_CATEGORIES,
) as string;
const categories = sentimentCategories
.split(',')
.map((cat) => cat.trim())
.filter(Boolean);
if (categories.length === 0) {
throw new NodeOperationError(this.getNode(), 'No sentiment categories provided', {
itemIndex: i,
});
}
// Initialize returnData with empty arrays for each category
if (returnData.length === 0) {
returnData.push(...Array.from({ length: categories.length }, () => []));
}
const options = this.getNodeParameter('options', i, {}) as {
systemPromptTemplate?: string;
includeDetailedResults?: boolean;
enableAutoFixing?: boolean;
};
const schema = z.object({
sentiment: z.enum(categories as [string, ...string[]]),
strength: zView on GitHub (pinned to 5ac6606e81)
Solutions
- Set 'Categories' under the node options to a comma-separated list like 'positive,negative,neutral'.
- If using an expression for categories, ensure it resolves to a non-empty comma-separated string.
- Remove the override so the default categories apply, or restore DEFAULT_CATEGORIES.
Example fix
// before
const categories = sentimentCategories.split(',').map((cat) => cat.trim()).filter(Boolean);
if (categories.length === 0) {
throw new NodeOperationError(this.getNode(), 'No sentiment categories provided', { itemIndex: i });
}
// after — fall back to defaults and warn instead of hard-failing
let categories = sentimentCategories.split(',').map((cat) => cat.trim()).filter(Boolean);
if (categories.length === 0) {
categories = DEFAULT_CATEGORIES.split(',').map((c) => c.trim()).filter(Boolean);
} Defensive patterns
Strategy: validation
Validate before calling
const raw = ctx.getNodeParameter('options.categories', i, DEFAULT_CATEGORIES) as string;
const categories = raw.split(',').map((c) => c.trim()).filter(Boolean);
if (categories.length === 0) {
throw new Error('Provide at least one sentiment category (e.g. positive,negative,neutral)');
} Type guard
function hasCategories(raw: string): boolean {
return raw.split(',').map((c) => c.trim()).filter(Boolean).length > 0;
} Prevention
- Set Categories to a non-empty comma-separated list.
- Avoid blank-only or comma-only values.
- Remove custom overrides to fall back to DEFAULT_CATEGORIES.
When it happens
Trigger: The categories option is blank, contains only commas/whitespace, or every token is empty after trimming. The filter(Boolean) removes all entries, leaving categories.length === 0.
Common situations: User cleared the categories field; the field contains only separators; the default (DEFAULT_CATEGORIES) was somehow overridden with an empty string via an expression or environment template.
Related errors
- The ‘text‘ parameter is empty.
- Invalid message type. Only imageBinary and imageUrl are supp
- No binary data set.
- The 'prompt' parameter is empty.
- Invalid message type
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/149ed868475af814.
Report an issue: GitHub.