Conversation
martmull
commented
Feb 24, 2026
- add integration test on sync manifest endpoint
- fix invalid standard uuid + migration command
| AND "universalIdentifier" = $3`, | ||
| [ | ||
| STANDARD_ROLE.admin.universalIdentifier, | ||
| workspaceId, | ||
| OLD_ROLE_ADMIN_UNIVERSAL_IDENTIFIER, | ||
| ], | ||
| ); | ||
|
|
||
| const roleUpdatedCount = roleResult?.[1] ?? 0; | ||
|
|
There was a problem hiding this comment.
Bug: The FixInvalidStandardUniversalIdentifiersCommand performs multiple database updates without wrapping them in a transaction, unlike other migration commands in the codebase.
Severity: HIGH
Suggested Fix
Wrap the sequence of UPDATE operations within a transaction using queryRunner.startTransaction() and queryRunner.commitTransaction(). Implement a try...catch block to call queryRunner.rollbackTransaction() on error, ensuring atomicity and preventing partial updates.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location:
packages/twenty-server/src/database/commands/upgrade-version-command/1-19/1-19-fix-invalid-standard-universal-identifiers.command.ts#L280-L289
Potential issue: The `FixInvalidStandardUniversalIdentifiersCommand` in
`1-19-fix-invalid-standard-universal-identifiers.command.ts` executes multiple `UPDATE`
queries on critical metadata tables (e.g., `role`, `agent`, `objectMetadata`). However,
these operations are not wrapped in a database transaction. This violates the
established pattern seen in other migration commands within the framework. If the
migration script is interrupted or fails partway through, the database will be left in a
partially updated, inconsistent state. This can lead to data corruption and break
metadata integrity for the affected workspace, as there is no automatic rollback
mechanism.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
1 issue found across 32 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/twenty-server/src/database/commands/upgrade-version-command/1-19/1-19-fix-invalid-standard-universal-identifiers.command.ts">
<violation number="1" location="packages/twenty-server/src/database/commands/upgrade-version-command/1-19/1-19-fix-invalid-standard-universal-identifiers.command.ts:269">
P2: Multiple UPDATE queries across different tables are executed without a transaction. If any query fails mid-way, the workspace will be left in a partially migrated state. Wrap the updates in a transaction using `queryRunner.startTransaction()`, `queryRunner.commitTransaction()`, and `queryRunner.rollbackTransaction()` in the catch/finally block.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| return; | ||
| } | ||
|
|
||
| const queryRunner = this.coreDataSource.createQueryRunner(); |
There was a problem hiding this comment.
P2: Multiple UPDATE queries across different tables are executed without a transaction. If any query fails mid-way, the workspace will be left in a partially migrated state. Wrap the updates in a transaction using queryRunner.startTransaction(), queryRunner.commitTransaction(), and queryRunner.rollbackTransaction() in the catch/finally block.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/twenty-server/src/database/commands/upgrade-version-command/1-19/1-19-fix-invalid-standard-universal-identifiers.command.ts, line 269:
<comment>Multiple UPDATE queries across different tables are executed without a transaction. If any query fails mid-way, the workspace will be left in a partially migrated state. Wrap the updates in a transaction using `queryRunner.startTransaction()`, `queryRunner.commitTransaction()`, and `queryRunner.rollbackTransaction()` in the catch/finally block.</comment>
<file context>
@@ -0,0 +1,359 @@
+ return;
+ }
+
+ const queryRunner = this.coreDataSource.createQueryRunner();
+
+ await queryRunner.connect();
</file context>
There was a problem hiding this comment.
Indeed with should have a query runner here just in case
Especially as we will perform the update on each command run
There was a problem hiding this comment.
Thanks for confirming!
Greptile SummaryThis PR adds comprehensive integration tests for the manifest sync endpoint and fixes invalid standard UUIDs across the codebase. The changes include:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 13fa995 |
prastoin
left a comment
There was a problem hiding this comment.
Quick review will check test and command in a second one
Thanks for taking this !
In the end we won't be validating the universal identifier uuid integrity in the common builder/validators ?
packages/twenty-shared/src/metadata/utils/compute-metadata-name-from-label.util.ts
Outdated
Show resolved
Hide resolved
...e-migration/workspace-migration-builder/builders/types/failed-flat-entity-validation.type.ts
Show resolved
Hide resolved
...ore-modules/application/utils/from-object-manifest-to-universal-flat-object-metadata.util.ts
Show resolved
Hide resolved
| return; | ||
| } | ||
|
|
||
| const queryRunner = this.coreDataSource.createQueryRunner(); |
There was a problem hiding this comment.
Indeed with should have a query runner here just in case
Especially as we will perform the update on each command run
...ands/upgrade-version-command/1-19/1-19-fix-invalid-standard-universal-identifiers.command.ts
Outdated
Show resolved
Hide resolved
...rc/database/commands/upgrade-version-command/1-19/constants/old-standard-objects.constant.ts
Outdated
Show resolved
Hide resolved
packages/twenty-shared/src/metadata/utils/compute-metadata-name-from-label.util.ts
Outdated
Show resolved
Hide resolved
|
Left comments :) |
0cab3b0 to
aa74039
Compare