Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions nodes/VlmRun/VlmRun.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
INodePropertyOptions,
INodeTypeDescription,
} from 'n8n-workflow';

import { FileRequest, ChatMessage, ResponseFormat } from './types';
import { ApiService } from './ApiService';
import { processFile, processImageRequest } from './utils';
Expand Down Expand Up @@ -68,25 +69,25 @@ export class VlmRun implements INodeType {
description: 'Extract insights or transcribe content from video files',
action: 'Analyze video',
},
{
name: 'Chat Completion',
value: 'chatCompletion',
description: 'Generate chat completions using OpenAI-compatible API',
action: 'Chat completion',
},
{
name: 'Execute Agent',
value: 'executeAgent',
description: 'Execute an agent',
action: 'Execute agent',
},
{
name: 'Manage Files',
value: 'file',
description: 'List uploaded files or upload new files to VLM Run',
action: 'Manage files',
},
{
name: 'Chat Completion',
value: 'chatCompletion',
description: 'Generate chat completions using OpenAI-compatible API',
action: 'Chat completion',
},
],
{
name: 'Manage Files',
value: 'file',
description: 'List uploaded files or upload new files to VLM Run',
action: 'Manage files',
},
],
default: 'document',
},
// File field for document, image, audio, video operations
Expand Down Expand Up @@ -893,7 +894,10 @@ export class VlmRun implements INodeType {

// Validate that if type is json_schema, schema must be provided
if (userDefinedResponseFormat.type === 'json_schema' && !userDefinedResponseFormat.schema) {
throw new Error('Schema is required when type is "json_schema"');
throw new NodeOperationError(
this.getNode(),
'Schema is required when type is "json_schema"',
);
Comment on lines +897 to +900
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While using NodeOperationError is generally best practice in n8n nodes, in this specific context it leads to a less clear error message for the user. The catch block on line 916 wraps this error into another NodeOperationError, prefixing the message with Invalid JSON format for response_format: .... This makes the specific validation error (Schema is required when type is "json_schema") appear as a generic JSON format error.

To provide a clearer error, it would be better to either keep throwing a standard Error which the catch block seems designed to handle, or refactor the catch block to re-throw NodeOperationError instances directly. Given the scope of this PR, reverting to new Error(...) seems more appropriate.

throw new Error('Schema is required when type is "json_schema"');

}

// For structured outputs (json_schema), ensure strict is set to true if not provided
Expand All @@ -904,7 +908,10 @@ export class VlmRun implements INodeType {
}
// If it's an empty object or doesn't have type/schema, treat as undefined (ignore it)
} else if (parsed !== undefined) {
throw new Error('Response format must be an object');
throw new NodeOperationError(
this.getNode(),
'Response format must be an object',
);
Comment on lines +911 to +914
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to my other comment, while using NodeOperationError is correct in principle, the catch block on line 916 will wrap this specific error inside a generic 'Invalid JSON format' error message. This can be confusing for the user. To ensure a clear and direct error message, it's better to throw a standard Error here, or to adjust the catch block to handle NodeOperationError differently. Since the catch block is not being changed, I recommend sticking with new Error(...) for now.

throw new Error('Response format must be an object');

}
} catch (error) {
throw new NodeOperationError(
Expand Down