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

feat(Execute Workflow Node): Move Type Conversion functionality to ResourceMapper #12268

Merged
merged 15 commits into from
Dec 19, 2024

Conversation

CharlieKolb
Copy link
Contributor

@CharlieKolb CharlieKolb commented Dec 17, 2024

Summary

Move ignoreTypeMismatchErrors and attemptToConvertTypes to the resourceMapper. This enables us to drop type checking in both node implementations, which kicked of some included refactoring.

The ugly part here is the inclusion of "constant" showTypeConversionOptions field in the resourceMapper schema, which indicates to parse strings rather than accept anything [1], which I believe to be much saner behavior.
I had to introduce this property to avoid changing existing use cases of the resourceMapper. Any mapper adopting the type options added here will also adopt this stricter string conversion automatically.

One change to call out here compared to the feature branch is that we're adopting resourceMapper's behavior of silently changing null to undefined when type-checking (though the sub-workflow trigger then replaces missing/undefined fields with null).
Previously (on the feature branch) we carried null and undefined over explicitly to support future default values for undefined, whereas null would be kept. However I suggest we keep the resourceMappper's behavior here in an attempt to stay in line. The implementation would be trivial in case the opposite is preferred.

Also includes an unrelated notice about node version for ExecuteWorkflow V1 and V1.1.

[1] I.e. resourceMappers elsewhere would accept 7 as a string and keep it a number, whereas new mappers would turn it into "7" under the hood.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/ADO-3017/feature-add-type-conversion-options-to-the-resourcemapper

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team node/improvement New feature or request ui Enhancement in /editor-ui or /design-system labels Dec 17, 2024
@CharlieKolb CharlieKolb marked this pull request as ready for review December 17, 2024 14:55
Copy link
Contributor

@MiloradFilipovic MiloradFilipovic left a comment

Choose a reason for hiding this comment

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

Looks good on my end (apart from failing tests). Left a few minor comments

cypress/e2e/48-subworkflow-inputs.cy.ts Show resolved Hide resolved
@@ -2729,6 +2730,9 @@ export type ResourceMapperValue = {
value: { [key: string]: string | number | boolean | null } | null;
matchingColumns: string[];
schema: ResourceMapperField[];
ignoreTypeMismatchErrors: boolean;
Copy link
Contributor

@MiloradFilipovic MiloradFilipovic Dec 18, 2024

Choose a reason for hiding this comment

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

Can you update our RMC documentation to include these new options once we merge this? I will also update the doc to include the new localResourceMapping method

Copy link

codecov bot commented Dec 19, 2024

@@ -1,3 +1,4 @@
import { loadWorkflowInputMappings } from 'n8n-nodes-base/dist/utils/workflowInputsResourceMapping/GenericFunctions';
Copy link
Contributor

Choose a reason for hiding this comment

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

My main reason for keeping these separate is for us to be able to customize them for the two nodes. Now realizing that they should behave the same and there is a bit of logic there to maintain to makes sense to unify it.

Copy link
Contributor Author

@CharlieKolb CharlieKolb Dec 19, 2024

Choose a reason for hiding this comment

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

Cool, I probably should have asked first, this just got caught up in the large merge conflict in general :D If we do modify behavior in the future it should probably still call a shared util in the end, so let's go with this 👍

@CharlieKolb CharlieKolb merged commit 08ae1a4 into feature-sub-workflow-inputs Dec 19, 2024
31 checks passed
@CharlieKolb CharlieKolb deleted the resourceMapperTypeConversion branch December 19, 2024 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team node/improvement New feature or request ui Enhancement in /editor-ui or /design-system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants