Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Validate values which are intentionally 0 #12382

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,47 @@ describe('validateValueAgainstSchema', () => {
// value should be type number
expect(typeof result).toEqual('number');
});

test('should validate when the value to be validated is 0, the mode is in Fixed mode, and the node is a resource mapper', () => {
const nodeType = {
description: {
properties: [
{
name: 'operation',
type: 'resourceMapper',
typeOptions: {
resourceMapper: {
mode: 'add',
},
},
},
],
},
} as unknown as INodeType;

const node = {
parameters: {
operation: {
schema: [
{
id: 'num',
type: 'number',
required: true,
},
],
attemptToConvertTypes: true,
mappingMode: '',
value: '',
},
},
} as unknown as INode;

const value = { num: 0 };

const parameterName = 'operation.value';

expect(() =>
validateValueAgainstSchema(node, nodeType, value, parameterName, 0, 0),
).not.toThrow();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const validateResourceMapperValue = (
!skipRequiredCheck &&
schemaEntry?.required === true &&
schemaEntry.type !== 'boolean' &&
!resolvedValue
resolvedValue === undefined
Copy link
Member

Choose a reason for hiding this comment

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

I don't actually know what the correct behavior here should be, but changing this means that now we will treat nulls and empty string also differently than before. Perhaps that is okay, perhaps it's now. Maybe we need to expand the check here to block both undefined and null.

) {
return {
valid: false,
Expand Down
Loading