Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

revert: "fix(pieces): stop offering the deprecated Todos piece where it can no longer run (#14982)" (#15581)

Louai Boumedienea6b1f9feed62
diff --git a/brain/knowledge/engineering/server-module-anatomy.md b/brain/knowledge/engineering/server-module-anatomy.md
index ea6d3253b2e..89f4672a17c 100644
--- a/brain/knowledge/engineering/server-module-anatomy.md
+++ b/brain/knowledge/engineering/server-module-anatomy.md
@@ -157,6 +157,7 @@ Verify with `npm run lint-dev` and `npm run test-api`.
- **No concurrency property can be tested in the api integration suite.** `.env.tests` runs PGlite, one in-process connection, so a second session cannot exist: `SELECT … FOR UPDATE` held from the test blocks nothing, two `Promise.all` requests serialise before either transaction opens, and a lost update is unobservable. A test written for a race there passes with the lock removed, which reads as proof and is the opposite. Measured Aug 2026 while adding a row lock to the agent draft-tools edit: deleting `setLock('pessimistic_write')` left all 13 tests green. So pin the user-visible invariant, mutation-test the parts that *are* observable (a name in a denylist, a guard's SQL), and say plainly in the commit that the lock rests on Postgres row semantics rather than a reproduced race. Row locks use `.createQueryBuilder().setLock('pessimistic_write')` inside `transaction(...)` — three of the four sites in the repo take that form. Better still, ask whether the coordination is needed at all: when two rows must agree, deriving one from the other at read time removes the class, while a lock only guards it and cannot be demonstrated here. That is how the agent-move race was settled in Sep 2026 — a run resolves its project from the agent row rather than from the conversation's copy of it, which is a pure function and therefore testable on any database.
- **`breaking = true` is the rollback-safety flag, not the customer-facing one.** It marks destructive DDL (`DROP TABLE`/`DROP COLUMN`, `ADD ... NOT NULL` without a default) for `rollback-migrations.ts`. It does *not* by itself mean the PR needs the `⛓️‍💥 breaking-change` label — decide that from upgrade impact on self-hosters and API consumers.
- **The destructive-DDL gate is a regex over `up()`, so a `DROP CONSTRAINT IF EXISTS` guard trips it even when nothing can be dropped.** `check-migration-rollback.ts` (via `breaking-change-scanners/migration-ddl.ts`) matches SQL text, not intent: pairing every `ADD CONSTRAINT` with a preceding `ALTER TABLE ... DROP CONSTRAINT IF EXISTS` for idempotency fails CI on a migration that only *creates* a table. Do not silence it by flipping `breaking = true` — that declares a perfectly rollbackable migration non-rollbackable and puts a false entry in the release rollback note. Declare the foreign keys inline in `CREATE TABLE IF NOT EXISTS` instead (as `1840000000000-AddFlowApprovalWorkflow.ts` does); the table's own `IF NOT EXISTS` already skips the whole statement, constraints included, so the drop/re-add buys nothing.
+- **Reverting a merged migration PR needs a hand-resolved conflict, and it does not unrun the migration.** GitHub's revert button fails ("couldn't be reverted automatically") as soon as another migration has been registered since yours: both the import block and the `getMigrations()` array put the new entry on the line next to the old one, so both hunks conflict. This is the one case where the usual union resolution is wrong — drop yours, keep the later one. The slot then becomes a hole in the sequence, which TypeORM does not mind, and the number stays safely reusable because migrations are matched by class name. The data is the real question: TypeORM records the migration as run and never revisits it, so the revert leaves every database that already executed `up()` in the new state, and deleting the class removes the only `down()`, putting it out of reach of `rollback-migrations.ts` too — copy that SQL out before you delete the file. To find out who has run it: `git tag --contains <sha>` empty means no release has it, `git merge-base --is-ancestor <sha> release-candidate` failing means cloud production has not, and staging has it either way, because `continuous-delivery-stg.yml` deploys every push to `main` (GIT-1778 / #14982, reverted 2026-09-16).
- **A new `AppSystemProp` needs three edits, not one.** Add the enum entry in `system-props.ts`, a default in `systemPropDefaultValues` (`system.ts`), *and* a validator in `systemPropValidators` (`system-validator.ts`). Miss the validator and `validateEnvPropsOnStartup` throws `systemPropValidators[prop] is not a function` at boot — every API test fails on setup, not just the new one. Document the var in `docs/install/reference/environment-variables.mdx` too.
- **`permission: undefined` on `securityAccess.project(...)` silently allows any project member.** The argument is required in practice even though the type tolerates omitting it.
- **Every query filters by `projectId` or `platformId`.** For connections with multi-project access, use `ArrayContains([projectId])` on the `projectIds` array column.
diff --git a/brain/knowledge/pieces-engine/pieces.md b/brain/knowledge/pieces-engine/pieces.md
index 6a5d632fbcf..822a042c5fa 100644
--- a/brain/knowledge/pieces-engine/pieces.md
+++ b/brain/knowledge/pieces-engine/pieces.md
@@ -23,7 +23,6 @@ The metadata catalog of automation integrations ("pieces") — each a named inte
- EE/Cloud per-piece and per-action/trigger visibility flows through `resolveVisibility` (`ee/pieces/filters/piece-filtering-utils.ts`), which returns a `VisibilityPolicy` or `null` on CE / when `platformId`/`projectId` is nil (callers treat `null` as no filtering). The policy is derived from the project's **piece set** (via `project.pieceSetId`, falling back to the platform Default).
- Install and sync also enqueue a tool-search reindex, but only when `isToolSearchEnabled()`; no-op otherwise.
- `delete` removes all versions sharing the name on that platform, and only for `CUSTOM` pieces the caller owns.
-- **Deleting a feature's backend does not stop the registry from shipping its piece — the rows must be capped by hand.** Published rows carry `maximumSupportedRelease: 99999.99999.9999`, and `isSupportedRelease` excludes a piece only when `release > max`, so the cloud registry keeps serving it to every self-hoster forever: the hourly sync installs it, the builder offers it, and every run 404s. `@activepieces/piece-todos` survived the deletion of its `/v1/todos` routes (0.79.0 restructure) that way for a year, until a customer hit it on 0.88.1 (GIT-1778). So whenever a removal PR deletes routes a piece calls, cap that piece's rows to the last release where it worked — a data `UPDATE` on `piece_metadata` shipped as a migration, which fixes the cloud registry (the source every self-hoster syncs from) and the local rows of self-hosters running with sync off. Knock-on effect to expect: `get` resolves through `findExactVersion`, which filters the registry by the server's release, so capping also turns existing steps into piece-not-found in the builder and at run start — earlier and clearer than the runtime 404, and the same end state the sync-delete reaches anyway.
- **A piece silently vanishes from the list when its `minimumSupportedRelease` is ahead of the root `package.json` version.** `fetchLatestPieces` filters every piece through `isSupportedRelease(apVersionUtil.getCurrentRelease(), piece)`. Pieces are routinely merged targeting the *next* release, so on `main` a couple dozen are invisible locally until the version bump lands. No warning is logged — it just isn't there.
- **`/v1/pieces` is uncached, so a new `piece_metadata` column must be added to `PIECE_COLUMNS_WITHOUT_TRANSLATIONS` or it silently will not appear in the list.** `pieceCache` caches only the *registry* (name/version/platformId tuples) for `get`/`findExactVersion`/`registry`; the list path never touches it, and the `dedupe()` helper in `piece-metadata-service.ts` is in-flight-only (it deletes the key in `finally`), so it collapses concurrent callers but caches nothing between requests. Every request therefore re-runs the whole pipeline against the DB. Because of that, `fetchLatestCompatiblePiecesFromDB` selects an explicit column list that deliberately omits `i18n` — that column holds every locale for the piece (~50 MB across the catalogue, written by `pieceInstallService`) and the list path discards it, so loading it was pure waste. Non-English requests now pull only the one locale in a second query (`pm."i18n" -> :locale`) and hand it to `pieceTranslation.translatePiece`, which also shrinks its `JSON.parse(JSON.stringify(...))` deep clone. The cost is that the explicit select is a list to keep in sync with the entity.
- **Piece sorting mutates its input, which is why the list result cannot simply be cached.** `pieceSorting`'s comparators and `reverseIfDesc` sort in place (`pieces.sort(...)`, `pieces.reverse()`). That is safe only because the array is rebuilt per request; making them non-mutating is a prerequisite for ever caching the built list, or requests would reorder shared state under each other. Same trap in `pieceTranslation.translatePiece`: when the piece has no entry for the locale it returns the *original* object rather than a clone, so any `piece.i18n = undefined` after it would mutate the shared row — take the no-translations branch before calling it.
diff --git a/packages/server/api/src/app/database/migration/postgres/1845000000000-CapTodosPieceMaxSupportedRelease.ts b/packages/server/api/src/app/database/migration/postgres/1845000000000-CapTodosPieceMaxSupportedRelease.ts
deleted file mode 100644
index bae8e8f42c4..00000000000
--- a/packages/server/api/src/app/database/migration/postgres/1845000000000-CapTodosPieceMaxSupportedRelease.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { QueryRunner } from 'typeorm'
-import { Migration } from '../../migration'
-
-export class CapTodosPieceMaxSupportedRelease1845000000000 implements Migration {
- name = 'CapTodosPieceMaxSupportedRelease1845000000000'
- breaking = false
- release = '0.91.0'
- transaction = true
-
- public async up(queryRunner: QueryRunner): Promise<void> {
- await queryRunner.query(`
- UPDATE "piece_metadata"
- SET "maximumSupportedRelease" = '0.78.2'
- WHERE "name" = '@activepieces/piece-todos'
- AND "pieceType" = 'OFFICIAL'
- `)
- }
-
- public async down(queryRunner: QueryRunner): Promise<void> {
- await queryRunner.query(`
- UPDATE "piece_metadata"
- SET "maximumSupportedRelease" = '99999.99999.9999'
- WHERE "name" = '@activepieces/piece-todos'
- AND "pieceType" = 'OFFICIAL'
- `)
- }
-}
diff --git a/packages/server/api/src/app/database/postgres-connection.ts b/packages/server/api/src/app/database/postgres-connection.ts
index 0279f9da00a..adb773bba82 100644
--- a/packages/server/api/src/app/database/postgres-connection.ts
+++ b/packages/server/api/src/app/database/postgres-connection.ts
@@ -437,7 +437,6 @@ import { AddPlatformConfiguration1841000000000 } from './migration/postgres/1841
import { AddAgentRunsIndex1842000000000 } from './migration/postgres/1842000000000-AddAgentRunsIndex'
import { AddAgentConversationFlowRunId1843000000000 } from './migration/postgres/1843000000000-AddAgentConversationFlowRunId'
import { AddMcpActivity1844000000000 } from './migration/postgres/1844000000000-AddMcpActivity'
-import { CapTodosPieceMaxSupportedRelease1845000000000 } from './migration/postgres/1845000000000-CapTodosPieceMaxSupportedRelease'
import { NullOrphanFolderReferences1846000000000 } from './migration/postgres/1846000000000-NullOrphanFolderReferences'
const getSslConfig = (): boolean | TlsOptions => {
@@ -891,7 +890,6 @@ export const getMigrations = (): (new () => Migration)[] => {
AddAgentRunsIndex1842000000000,
AddAgentConversationFlowRunId1843000000000,
AddMcpActivity1844000000000,
- CapTodosPieceMaxSupportedRelease1845000000000,
NullOrphanFolderReferences1846000000000,
]
return migrations