fix(editor): Disable fromAI override button for credentialsSelect (no-changelog) (#13314)

This commit is contained in:
Charlie Kolb 2025-02-19 12:27:37 +01:00 committed by GitHub
parent 143cb22bc5
commit 301f5a50d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View File

@ -6,16 +6,20 @@ import {
makeOverrideValue,
parseOverrides,
} from './fromAIOverrideUtils';
import type { INodeTypeDescription } from 'n8n-workflow';
import type { INodeTypeDescription, NodePropertyTypes } from 'n8n-workflow';
const DISPLAY_NAME = 'aDisplayName';
const PARAMETER_NAME = 'aName';
const makeContext = (value: string, path?: string): OverrideContext => ({
const makeContext = (
value: string,
path?: string,
type: NodePropertyTypes = 'string',
): OverrideContext => ({
parameter: {
name: PARAMETER_NAME,
displayName: DISPLAY_NAME,
type: 'string',
type,
},
value,
path: path ?? `parameters.${PARAMETER_NAME}`,
@ -77,6 +81,7 @@ describe('makeOverrideValue', () => {
['ai node type on denylist', makeContext(''), AI_DENYLIST_NODE_TYPE],
['vector store type', makeContext(''), AI_VECTOR_STORE_NODE_TYPE],
['denied parameter name', makeContext('', 'parameters.toolName'), AI_NODE_TYPE],
['denied parameter type', makeContext('', undefined, 'credentialsSelect'), AI_NODE_TYPE],
])('should not create an override for %s', (_name, context, nodeType) => {
expect(makeOverrideValue(context, nodeType)).toBeNull();
});

View File

@ -55,6 +55,8 @@ const PATH_DENYLIST = [
'parameters.toolDescription',
];
const PROP_TYPE_DENYLIST = ['options', 'credentialsSelect'];
export const fromAIExtraProps: Record<FromAIExtraProps, ExtraPropValue> = {
description: {
initialValue: '',
@ -165,6 +167,8 @@ export function canBeContentOverride(
if (PATH_DENYLIST.includes(props.path)) return false;
if (PROP_TYPE_DENYLIST.includes(props.parameter.type)) return false;
const codex = nodeType?.codex;
if (
!codex?.categories?.includes('AI') ||
@ -173,7 +177,7 @@ export function canBeContentOverride(
)
return false;
return !props.parameter.noDataExpression && 'options' !== props.parameter.type;
return !props.parameter.noDataExpression;
}
export function makeOverrideValue(