Commit graph

2382 commits

Author SHA1 Message Date
कारतोफ्फेलस्क्रिप्ट™ cfe9525dd4
fix(core): Better input validation for the changeRole endpoint (#8189)
also refactored the code to
1. stop passing around `scope === 'global'`, since this code can be used
only for changing globalRole.
2. leak less details when input validation fails.

## Review / Merge checklist
- [x] PR title and summary are descriptive
- [x] Tests included
2024-01-03 09:33:35 +01:00
Iván Ovejero 40c1eeeddd
refactor(core): Continue moving typeorm operators to repositories (no-changelog) (#8186)
Follow-up to: #8163
2024-01-02 17:53:24 +01:00
Tomi Turtiainen e126ed74f3
feat(core): Add user.profile.beforeUpdate hook (#8144)
Add `user.profile.beforeUpdate` hook so we can prevent user email change
if it overlaps with other users email.
2024-01-02 10:15:12 +02:00
Iván Ovejero ece48d6a13
refactor(core): Unify workflow controllers (no-changelog) (#8175)
Combine EE workflows controller into main workflows controller,
protecting paid functionality behind feature flag checks.
2023-12-29 14:23:58 +01:00
Iván Ovejero 4bad43dd66
refactor(core): Move typeorm operators from WaitTracker to ExecutionRepository (no-changelog) (#8163)
Follow-up to: #8145

---------

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
2023-12-28 19:22:09 +01:00
Iván Ovejero e418d42450
refactor(core): Move typeorm operators from various sources into repositories (no-changelog) (#8174)
Follow-up to: #8165
2023-12-28 13:14:10 +01:00
कारतोफ्फेलस्क्रिप्ट™ c84d3c3bbf
refactor(core): Extract ActiveWebhooks out of ActiveWorkflowRunner (no-changelog) (#8171)
## Summary
This PR continues refactoring webhooks code for better modularity.
Continued from #8069 to bring back `ActiveWebhooks`, but this time
actually handling active webhook calls in this class.

## Review / Merge checklist
- [x] PR title and summary are descriptive
2023-12-28 10:04:32 +01:00
Iván Ovejero 639afcd7a5
refactor(core): Simplify state in test webhooks (no-changelog) (#8155)
This PR simplifies state in test webhooks so that it can be cached
easily. Caching this state will allow us to start using Redis for manual
webhooks, to support manual webhooks to work in multi-main setup.

- [x] Convert `workflowWebhooks` to a getter - no need to optimize for
deactivation
- [x] Remove array from value in `TestWebhooks.webhookUrls`
- [x] Consolidate `webhookUrls` and `registeredWebhooks`
2023-12-28 09:28:12 +01:00
Iván Ovejero 0e582594ea
refactor(core): Move more typeorm operators to UserRepository (no-changelog) (#8165)
Follow-up to: #8163
2023-12-28 09:27:47 +01:00
Iván Ovejero 5aee7a1d48
refactor(core): Move typeorm operators from SourceControlExportService to repositories (no-changelog) (#8168)
Follow-up to: #8165
2023-12-28 09:27:38 +01:00
Jan Oberhauser ea7e76fa3b
fix(core): Use pinned data only for manual mode (#8164)
## Summary
Fixes the issue that pinned data gets also used for production executions.

---------

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
2023-12-27 18:22:33 +01:00
Iván Ovejero 2c6ffb0153
fix(core): Minor improvements to multi-main setup (no-changelog) (#8012)
- Move webhook, poller and trigger activation logs closer to activation
event
- Enrich response of `/debug/multi-main-setup`
- Ensure workflow updates broadcast activation state changes only if
state changed
- Fix bug on workflow activation after leadership change
- Ensure debug controller is not available in production

---------

Co-authored-by: Omar Ajoue <krynble@gmail.com>
2023-12-27 16:55:01 +01:00
कारतोफ्फेलस्क्रिप्ट™ f69ddcd796
refactor(core): Use Dependency Injection for all Controller classes (no-changelog) (#8146)
## Review / Merge checklist
- [x] PR title and summary are descriptive
2023-12-27 11:50:43 +01:00
Jan Oberhauser fa8bd8b9eb
fix(core): Fix issue that pinnedData is not used with Test-Webhooks (#8123)
## Summary
When a workflow gets started via a Test-Webhook the pinned data does get
ignored and the nodes executed anyway.



## Related tickets and issues
> Include links to **Linear ticket** or Github issue or Community forum
post. Important in order to close *automatically* and provide context to
reviewers.



## Review / Merge checklist
- [x] PR title and summary are descriptive. **Remember, the title
automatically goes into the changelog. Use `(no-changelog)` otherwise.**
([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md))
- [ ] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up
ticket created.
- [X] Tests included.
> A bug is not considered fixed, unless a test is added to prevent it
from happening again.
   > A feature is not complete without tests.

---------

Co-authored-by: Mutasem Aldmour <mutasem@n8n.io>
2023-12-27 10:51:53 +01:00
Iván Ovejero 7b26a7a621
refactor(core): Move typeorm operators from PruningService to ExecutionRepository (no-changelog) (#8145)
Follow-up to https://github.com/n8n-io/n8n/pull/8143
2023-12-22 17:49:15 +01:00
Iván Ovejero a59d78de18
refactor(core): Move more typeorm operators to repositories (no-changelog) (#8143)
Follow-up to #8139
2023-12-22 16:20:30 +01:00
कारतोफ्फेलस्क्रिप्ट™ 4007163651
refactor(core): Delete unused code, and fix typings in tests (no-changelog) (#8142) 2023-12-22 15:41:29 +01:00
कारतोफ्फेलस्क्रिप्ट™ baee47a276
refactor(core): Move all base URLs to UrlService (no-changelog) (#8141)
This change kept coming up in #6713, #7773, and #8135. 
So this PR moves the existing code without actually changing anything,
to help get rid of some of the circular dependencies.


## Review / Merge checklist
- [x] PR title and summary are descriptive.
2023-12-22 15:19:50 +01:00
Iván Ovejero c6dd935895
refactor(core): Move some typeorm operators to repositories (no-changelog) (#8139)
Moving some persistence logic to repositories to reduce circular
dependencies.
2023-12-22 13:35:23 +01:00
Tomi Turtiainen 3a881be6c2
feat(core): Unify application components shutdown (#8097)
## Summary

Add `ShutdownService` and `OnShutdown` decorator for more unified way to
shutdown different components. Use this new way in the following
components:

- HTTP(S) server
- Pruning service
- Push connection
- License

---------

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
2023-12-22 12:39:58 +02:00
कारतोफ्फेलस्क्रिप्ट™ c158ca2471
refactor(core): Upgrade more dependencies to remove axios 0.x (no-changelog) (#8105)
Had to [fork localtunnel](https://github.com/n8n-io/localtunnel) to get
the axios upgrade, since localtunnel doesn't seem to be actively maintained.
2023-12-22 11:39:20 +01:00
कारतोफ्फेलस्क्रिप्ट™ 021add0f39
refactor(core): Move active workflows endpoints to a decorated controller class (no-changelog) (#8101)
This is a continuation of migrating all rest endpoints to decorated controller classes
2023-12-22 11:28:42 +01:00
कारतोफ्फेलस्क्रिप्ट™ 21788d9153
fix(core): Remove circular dependency in WorkflowService and ActiveWorkflowRunner (#8128)
## Summary
A circular dependency between `WorkflowService` and
`ActiveWorkflowRunner` is sometimes causing `this.activeWorkflowRunner`
to be `undefined` in `WorkflowService`.
Breaking this circular dependency should hopefully fix this issue.

## Related tickets and issues
#8122


## Review / Merge checklist
- [x] PR title and summary are descriptive
- [ ] Tests included
2023-12-21 17:37:08 +01:00
कारतोफ्फेलस्क्रिप्ट™ ffaa30ddc4
fix(core): Handle empty executions table in pruning in migrations (#8121)
In case someone manually prunes their executions table before upgrading
to 1.x, `MigrateIntegerKeysToString` should gracefully handle that,
instead of crashing the application.

## Review / Merge checklist
- [x] PR title and summary are descriptive
2023-12-21 14:52:42 +01:00
Iván Ovejero 9ac8825a67
refactor(core): Move error execution creation to execution service (no-changelog) (#8006)
Continue breaking down legacy helpers.

Note: `getUserById` is unused.
2023-12-21 14:15:46 +01:00
Iván Ovejero d1b2affd2c
ci: Add lint rule no-dynamic-import-template (no-changelog) (#8089)
Follow-up to: https://github.com/n8n-io/n8n/pull/8086

`tsc-alias` as of 1.8.7 is unable to resolve template strings in dynamic
imports. Since the module name mapper in Jest is able to, this issue is
hard to detect, hence the new lint rule `no-dynamic-import-template`.
This is for now specific to `@/` in the `cli` package - we can
generalize later if needed. Ideally we should contribute a fix upstream
when we have more time.

<img width="940" alt="Capture 2023-12-19 at 12 39 55@2x"
src="https://github.com/n8n-io/n8n/assets/44588767/78d4a277-ccff-455c-8610-d1bba39d93f2">
2023-12-21 14:15:37 +01:00
कारतोफ्फेलस्क्रिप्ट™ 01e9a79238
feat(core): Remove discontinued crypto-js (#8104)
Since crypto-js was
[discontinued](1da3dabf93),
[we migrated all our backend encryption to native
crypto](https://github.com/n8n-io/n8n/pull/7556).
However I decided back then to not remove crypto-js just yet in
expressions, as I wanted to use `SubtleCrypto`. Unfortunately for that
to work, we'd need to make expressions async.
So, to get rid of `crypto-js`, I propose this interim solution. 

## Related tickets and issues
N8N-7020

## Review / Merge checklist
- [x] PR title and summary are descriptive
- [x] Tests included
2023-12-21 14:13:02 +01:00
github-actions[bot] b67b5ae6b2
🚀 Release 1.22.0 (#8115)
#
[1.22.0](https://github.com/n8n-io/n8n/compare/n8n@1.21.0...n8n@1.22.0)
(2023-12-21)


### Bug Fixes

* **core:** Close db connection gracefully when exiting
([#8045](https://github.com/n8n-io/n8n/pull/8045))
([e69707e](e69707efd4))
* **core:** Consider timeout in shutdown an error
([#8050](https://github.com/n8n-io/n8n/pull/8050))
([4cae976](4cae976a3b))
* **core:** Do not display error when stopping jobless execution in
queue mode ([#8007](https://github.com/n8n-io/n8n/pull/8007))
([8e6b951](8e6b951a76))
* **core:** Fix shutdown if terminating before hooks are initialized
([#8047](https://github.com/n8n-io/n8n/pull/8047))
([6ae2f5e](6ae2f5efea))
* **core:** Handle multiple termination signals correctly
([#8046](https://github.com/n8n-io/n8n/pull/8046))
([67bd8ad](67bd8ad698))
* **core:** Initialize queue once in queue mode
([#8025](https://github.com/n8n-io/n8n/pull/8025))
([53c0b49](53c0b49d15))
* **core:** Prevent axios from force setting a form-urlencoded
content-type ([#8117](https://github.com/n8n-io/n8n/pull/8117))
([bba9576](bba95761e2))
* **core:** Remove circular references before serializing executions in
public API ([#8043](https://github.com/n8n-io/n8n/pull/8043))
([989888d](989888d9bc))
* **core:** Restore workflow ID during execution creation
([#8031](https://github.com/n8n-io/n8n/pull/8031))
([c5e6ba8](c5e6ba8cdd))
* **core:** Use relative imports for dynamic imports in
SecurityAuditService ([#8086](https://github.com/n8n-io/n8n/pull/8086))
([785bf99](785bf9974e))
* **core:** Stop binary data restoration from preventing execution from
finishing ([#8082](https://github.com/n8n-io/n8n/pull/8082))
([5ffff1b](5ffff1bb22))
* **editor:** Add back credential `use` permission
([#8023](https://github.com/n8n-io/n8n/pull/8023))
([329e5bf](329e5bf9ee))
* **editor:** Cleanup Executions page component
([#8053](https://github.com/n8n-io/n8n/pull/8053))
([2689c37](2689c37e87))
* **editor:** Disable auto scroll and list size check when clicking on
executions ([#7983](https://github.com/n8n-io/n8n/pull/7983))
([fcb8b91](fcb8b91f37))
* **editor:** Ensure execution data overrides pinned data when copying
in executions view ([#8009](https://github.com/n8n-io/n8n/pull/8009))
([1d1cb0d](1d1cb0d3c5))
* **editor:** Fix copy/paste issue when switch node is in workflow
([#8103](https://github.com/n8n-io/n8n/pull/8103))
([4b86926](4b86926752))
* **editor:** Make keyboard shortcuts more strict; don't accept extra
Ctrl/Alt/Shift keys ([#8024](https://github.com/n8n-io/n8n/pull/8024))
([8df49e1](8df49e134d))
* **editor:** Show credential share info only to appropriate users
([#8020](https://github.com/n8n-io/n8n/pull/8020))
([b29b4d4](b29b4d442b))
* **editor:** Turn off executions list auto-refresh after leaving the
page ([#8005](https://github.com/n8n-io/n8n/pull/8005))
([e3c363d](e3c363d72c))
* **editor:** Update image sizes in template description not to be full
width always ([#8037](https://github.com/n8n-io/n8n/pull/8037))
([63a6e7e](63a6e7e034))
* **ActiveCampaign Node:** Fix pagination issue when loading tags
([#8017](https://github.com/n8n-io/n8n/pull/8017))
([1943857](1943857231))
* **HTTP Request Node:** Do not create circular references in HTTP
request node output ([#8030](https://github.com/n8n-io/n8n/pull/8030))
([5b7ea16](5b7ea16d9a))
* Upgrade axios to address CVE-2023-45857
([#7713](https://github.com/n8n-io/n8n/pull/7713))
([64eb9bb](64eb9bbc36))


### Features

* Add option to `returnIntermediateSteps` for AI agents
([#8113](https://github.com/n8n-io/n8n/pull/8113))
([7806a65](7806a65229))
* **core:** Add config option to prefer GET request over LIST when using
Hashicorp Vault ([#8049](https://github.com/n8n-io/n8n/pull/8049))
([439a22d](439a22d68f))
* **core:** Add N8N_GRACEFUL_SHUTDOWN_TIMEOUT env var
([#8068](https://github.com/n8n-io/n8n/pull/8068))
([614f488](614f488386))
* **editor:** Add lead enrichment suggestions to workflow list
([#8042](https://github.com/n8n-io/n8n/pull/8042))
([36a923c](36a923cf7b))
* **editor:** Finalize workers view
([#8052](https://github.com/n8n-io/n8n/pull/8052))
([edfa784](edfa78414d))
* **editor:** Gracefully ignore invalid payloads in postMessage handler
([#8096](https://github.com/n8n-io/n8n/pull/8096))
([9d22c7a](9d22c7a278))
* **editor:** Upgrade frontend tooling to address a few vulnerabilities
([#8100](https://github.com/n8n-io/n8n/pull/8100))
([19b7f1f](19b7f1ffb1))
* **Filter Node:** Overhaul UI by adding the new filter component
([#8016](https://github.com/n8n-io/n8n/pull/8016))
([3d53052](3d530522f8))
* **Respond to Webhook Node:** Overhaul with improvements like returning
all items ([#8093](https://github.com/n8n-io/n8n/pull/8093))
([32d397e](32d397eff3))


### Performance Improvements

* **editor:** Improve canvas rendering performance
([#8022](https://github.com/n8n-io/n8n/pull/8022))
([b780436](b780436a6b))

Co-authored-by: ivov <ivov@users.noreply.github.com>
2023-12-21 13:51:24 +01:00
Omar Ajoue 5ffff1bb22
fix: Stop binary data restoration from preventing execution from finishing (#8082)
In the case of a filesystem failure to rename the binary files as part
of the execution's cleanup process, the execution would fail to be saved
and would never finish. This catch prevents it.

## Summary
Whenever an execution is wrapping u to save the data, if it uses binary
data n8n will try to find possibly misallocated files and place them in
the right folder. If this process fails, the execution fails to finish.

Given the execution has already finished at this point, and we cannot
handle the binary data errors more gracefully, all we can do at this
point is log the message as it's a filesystem issue. The rest of the
execution saving process should remain as normal.



## Related tickets and issues
https://linear.app/n8n/issue/HELP-430



## Review / Merge checklist
- [ ] PR title and summary are descriptive. **Remember, the title
automatically goes into the changelog. Use `(no-changelog)` otherwise.**
([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md))
- [ ] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up
ticket created.
- [ ] Tests included.
> A bug is not considered fixed, unless a test is added to prevent it
from happening again.
   > A feature is not complete without tests.

---------

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
2023-12-21 09:40:39 +00:00
Iván Ovejero edfa78414d
feat(editor): Finalize workers view (#8052)
https://linear.app/n8n/issue/PAY-1065
2023-12-20 17:49:14 +01:00
Iván Ovejero 97aa38e783
ci: Fix Postgres and MySQL tests (no-changelog) (#8106)
This role query works for sqlite but [fails for Postgres and
MySQL](https://github.com/n8n-io/n8n/actions/runs/7269009778/job/19805986017),
so generalize by adding alias and accounting for count possibly being
`string` in the resulting rows.

Run in progress: https://github.com/n8n-io/n8n/actions/runs/7275986797
2023-12-20 15:14:31 +01:00
कारतोफ्फेलस्क्रिप्ट™ 81994ce13d
fix(core): Downgrade Rudderstack SDK (no-changelog) (#8107)
This reverts commit a895ee87fc (#8090)

Our telemetry backend is throwing 500s with the updated rudderstack sdk.
Until that is resolved, we need to downgrade.

## Review / Merge checklist
- [x] PR title and summary are descriptive
2023-12-20 11:59:44 +01:00
Iván Ovejero 9dc491c3a5
refactor(core): Improve test-webhooks (no-changelog) (#8069)
Remove duplication, improve readability, and expand tests for
`TestWebhooks.ts` - in anticipation for storing test webhooks in Redis.

---------

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
2023-12-19 17:32:02 +01:00
Iván Ovejero 38d1336fa7
refactor: Add telemetry for RBAC (no-changelog) (#8056)
https://linear.app/n8n/issue/PAY-1142
2023-12-19 17:02:52 +01:00
कारतोफ्फेलस्क्रिप्ट™ a895ee87fc
feat(core): Upgrade Rudderstack SDK (no-changelog) (#8090)
This helps remove some of the older versions of transient dependencies,
like axios 0.x and ioredis 4.x.

## Review / Merge checklist
- [x] PR title and summary are descriptive.
2023-12-19 16:53:12 +01:00
कारतोफ्फेलस्क्रिप्ट™ 64eb9bbc36
fix: Upgrade axios to address CVE-2023-45857 (#7713)
[GH Advisory](https://github.com/advisories/GHSA-wf5p-g6vw-rhxx)
2023-12-19 16:17:01 +01:00
Iván Ovejero 8e6b951a76
fix(core): Do not display error when stopping jobless execution in queue mode (#8007)
No need to surface error to user when stopping a job no longer in queue.

https://linear.app/n8n/issue/PAY-1104
2023-12-19 16:11:21 +01:00
कारतोफ्फेलस्क्रिप्ट™ 464b565283
ci: Remove unnecessary async/await, enable await-thenable linting rule (no-changelog) (#8076)
## Summary
We accidentally made some functions `async` in
https://github.com/n8n-io/n8n/pull/7846
This PR reverts that change. 

## Review / Merge checklist
- [x] PR title and summary are descriptive.
2023-12-19 13:52:42 +01:00
कारतोफ्फेलस्क्रिप्ट™ 785bf9974e
fix(core): Use relative imports for dynamic imports in SecurityAuditService (#8086)
`tsc-alias` doesn't seem to replace imports when using template strings

## Related tickets and issues
#8085

## Review / Merge checklist
- [x] PR title and summary are descriptive.
2023-12-19 12:41:15 +01:00
कारतोफ्फेलस्क्रिप्ट™ a63d94f28c
refactor(core): Move license endpoints to a decorated controller class (no-changelog) (#8074) 2023-12-19 12:13:19 +01:00
Iván Ovejero 73d400a1bf
refactor(core): Inject dependencies into workflow services (no-changelog) (#8066)
Inject dependencies into workflow services (no-changelog)

Up next:

- ~~Make workflow services injectable~~ #8033
- ~~Inject dependencies into workflow services~~ (current)
- Consolidate workflow controllers into one
- Make workflow controller injectable
- Inject dependencies into workflow controller
2023-12-18 16:10:30 +01:00
कारतोफ्फेलस्क्रिप्ट™ a651089a10
refactor(core): Update backend sentry setup to reduce noise (no-changelog) (#8026)
## Summary
This PR updates our backend sentry setup to remove integrations that
don't provide us any value. This also reduces the amount of PII that
gets sent to Sentry.

[Sample event](https://n8nio.sentry.io/issues/4725315362/)

## Related tickets
[ENG-95](https://linear.app/n8n/issue/ENG-95)

## Review / Merge checklist
- [x] PR title and summary are descriptive.
2023-12-18 14:26:07 +01:00
Tomi Turtiainen 614f488386
feat(core): Add N8N_GRACEFUL_SHUTDOWN_TIMEOUT env var (#8068)
Add generic N8N_GRACEFUL_SHUTDOWN_TIMEOUT which controls how long n8n
process will wait for graceful exit before exitting forcefully. This
variables replaces the QUEUE_WORKER_TIMEOUT variable that was used for
worker process.

DEPRECATED: QUEUE_WORKER_TIMEOUT deprected

QUEUE_WORKER_TIMEOUT environment variable has been replaced with
N8N_GRACEFUL_SHUTDOWN_TIMEOUT.
2023-12-18 14:04:19 +02:00
Tomi Turtiainen 4cae976a3b
fix(core): Consider timeout in shutdown an error (#8050)
If the process doesn't shutdown within a time limit, exit with error
code.

1. conceptually something timing out is an error.
2. on successful exit we close down the DB connection gracefully. On an
exit timeout we rather not do that, since it will wait for any active
connections to close and would possible block the exit.
2023-12-18 10:53:34 +02:00
Tomi Turtiainen 6ae2f5efea
fix(core): Fix shutdown if terminating before hooks are initialized (#8047)
If the app receives termination signal before hooks have been
initialised, the would be objet is undefined error. This PR fixes that.
2023-12-18 09:23:10 +02:00
Jon 439a22d68f
feat: Add config option to prefer GET request over LIST when using Hashicorp Vault (#8049)
## Summary
Hashicorp Vault prefers a `LIST` HTTP method to be used when fetching
secrets but not all environments will allow custom http methods through
WAFs. This PR adds `N8N_EXTERNAL_SECRETS_PREFER_GET` which when set to
`true` will use GET instead of LIST to fetch secrets.


## Review / Merge checklist
- [x] PR title and summary are descriptive. **Remember, the title
automatically goes into the changelog. Use `(no-changelog)` otherwise.**
([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md))
2023-12-15 16:20:39 +00:00
Tomi Turtiainen 67bd8ad698
fix(core): Handle multiple termination signals correctly (#8046)
Prevent possible multiple termination signals initiating the shutdown
process multiple times.
2023-12-15 17:35:22 +02:00
Tomi Turtiainen e69707efd4
fix(core): Close db connection gracefully when exiting (#8045)
Close db connection gracefully when exiting
2023-12-15 17:16:35 +02:00
Marcus 48d4f4a71b
fix(core): Public API support node's deprecated continueOnFail to upload old workflows (no-changelog) (#8044) 2023-12-15 16:11:53 +01:00
कारतोफ्फेलस्क्रिप्ट™ 989888d9bc
fix(core): Remove circular references before serializing executions in public API (#8043)
## Summary
Handle circular references in the public API for executions created
prior to the fix from #8030

## Related tickets
[PAY-1119](https://linear.app/n8n/issue/PAY-1119)

## Review / Merge checklist
- [x] PR title and summary are descriptive.
2023-12-15 16:01:41 +01:00