-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
feat: Better error when calling expression function on input that is undefined or null #10009
Merged
michael-radency
merged 4 commits into
master
from
node-1454-filterifswitch-nodes-improve-output-panel-error-if-a-field
Jul 11, 2024
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d337810
fix
michael-radency cbd6702
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1454…
michael-radency f7a3a24
review update
michael-radency f690a13
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1454…
michael-radency File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,10 @@ | |
|
||
/* eslint-disable n8n-local-rules/no-interpolation-in-regular-string */ | ||
|
||
import { extendTransform } from '@/Extensions'; | ||
import { extendTransform, extend } from '@/Extensions'; | ||
import { joinExpression, splitExpression } from '@/Extensions/ExpressionParser'; | ||
import { evaluate } from './Helpers'; | ||
import { ExpressionExtensionError } from '../../src/errors/expression-extension.error'; | ||
|
||
describe('Expression Extension Transforms', () => { | ||
describe('extend() transform', () => { | ||
|
@@ -242,4 +243,31 @@ describe('tmpl Expression Parser', () => { | |
expect(evaluate('={{ $ifEmpty({a: 1}, "default") }}')).toEqual({ a: 1 }); | ||
}); | ||
}); | ||
|
||
describe('Test estend with undefined', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo... extend |
||
test('input is undefined', () => { | ||
try { | ||
extend(undefined, 'toDateTime', []); | ||
} catch (error) { | ||
expect(error).toBeInstanceOf(ExpressionExtensionError); | ||
expect(error).toHaveProperty( | ||
'message', | ||
'toDateTime() could not be called on "undefined" type', | ||
); | ||
} | ||
}); | ||
test('input is null', () => { | ||
try { | ||
extend(null, 'startsWith', []); | ||
} catch (error) { | ||
expect(error).toBeInstanceOf(ExpressionExtensionError); | ||
expect(error).toHaveProperty('message', 'startsWith() could not be called on "null" type'); | ||
} | ||
}); | ||
test('input should be converted to upper case', () => { | ||
const result = extend('TEST', 'toUpperCase', []); | ||
|
||
expect(result).toEqual('TEST'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight tweak