-
Notifications
You must be signed in to change notification settings - Fork 261
fix: fixed exceptions that were throws for cf on unsupported flows & … #3466
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
base: dev
Are you sure you want to change the base?
fix: fixed exceptions that were throws for cf on unsupported flows & … #3466
Conversation
|
WalkthroughThis update introduces a new utility module and service for determining collection flow state support, integrates them into relevant modules, and updates services to utilize this logic. Supporting utilities were added for Prisma exception handling. Some legacy logic was removed and early returns were introduced for unsupported states. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant DocumentService
participant CollectionFlowUtilityService
participant WorkflowService
participant UiDefinitionService
Client->>DocumentService: getDocumentTrackerByWorkflowId(projectId, workflowId)
DocumentService->>CollectionFlowUtilityService: isCollectionFlowStateSupported(workflowId, projectId)
CollectionFlowUtilityService->>WorkflowService: getWorkflowByIdWithRelations(workflowId, projectId)
WorkflowService-->>CollectionFlowUtilityService: workflowDefinition
CollectionFlowUtilityService->>UiDefinitionService: getUiDefinition(workflowDefinition, 'collection_flow')
alt UI definition found
UiDefinitionService-->>CollectionFlowUtilityService: uiDefinition
CollectionFlowUtilityService-->>DocumentService: true
DocumentService->>DocumentService: Continue normal logic
else UI definition not found (P2025)
CollectionFlowUtilityService-->>DocumentService: false
DocumentService-->>Client: Return default empty tracker
end
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
services/workflows-service/src/common/is-prisma-exception/is-prisma-exception.ts (1)
5-6: Consider a more robust type guard implementation.The current implementation only checks for a
codeproperty, which could lead to false positives with other error objects that have acodestring property.Consider a more comprehensive check:
-export const isPrismaException = (value: unknown): value is PrismaClientKnownRequestError => - isType(z.object({ code: z.string() }))(value); +export const isPrismaException = (value: unknown): value is PrismaClientKnownRequestError => + isType(z.object({ + code: z.string(), + meta: z.unknown().optional(), + message: z.string() + }))(value) && value instanceof PrismaClientKnownRequestError;Alternatively, you could use a more targeted schema that matches PrismaClientKnownRequestError properties more precisely.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
services/workflows-service/prisma/data-migrations(1 hunks)services/workflows-service/src/collection-flow/collection-flow.module.ts(2 hunks)services/workflows-service/src/collection-flow/services/collection-flow-state.service.ts(3 hunks)services/workflows-service/src/collection-flow/services/сollection-flow-utility/collection-flow-utility.module.ts(1 hunks)services/workflows-service/src/collection-flow/services/сollection-flow-utility/collection-flow-utility.service.ts(1 hunks)services/workflows-service/src/common/is-prisma-exception/is-prisma-exception.ts(1 hunks)services/workflows-service/src/document/document.module.ts(2 hunks)services/workflows-service/src/document/document.service.ts(4 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/workflows-service.mdc:0-0
Timestamp: 2025-06-24T09:37:14.531Z
Learning: Use the PrismaService for all database operations and wrap multiple operations in transactions for atomicity.
services/workflows-service/prisma/data-migrations (2)
undefined
<retrieved_learning>
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/data-migrations.mdc:0-0
Timestamp: 2025-06-24T09:35:54.963Z
Learning: In Ballerine's workflow migration scripts (TypeScript), always establish the relationship between workflow definitions and UI definitions solely through the 'workflowDefinitionId' field in the UiDefinition model; do not create a separate junction table or relation.
</retrieved_learning>
<retrieved_learning>
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/data-migrations.mdc:0-0
Timestamp: 2025-06-24T09:35:54.963Z
Learning: Use consistent naming conventions for related components (workflows, UI definitions, filters) in Ballerine migrations to improve maintainability and clarity.
</retrieved_learning>
services/workflows-service/src/document/document.module.ts (1)
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/data-migrations.mdc:0-0
Timestamp: 2025-06-24T09:35:54.963Z
Learning: In Ballerine's workflow migration scripts (TypeScript), always establish the relationship between workflow definitions and UI definitions solely through the 'workflowDefinitionId' field in the UiDefinition model; do not create a separate junction table or relation.
services/workflows-service/src/collection-flow/services/collection-flow-state.service.ts (2)
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/data-migrations.mdc:0-0
Timestamp: 2025-06-24T09:35:54.963Z
Learning: In Ballerine's workflow migration scripts (TypeScript), always establish the relationship between workflow definitions and UI definitions solely through the 'workflowDefinitionId' field in the UiDefinition model; do not create a separate junction table or relation.
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/workflows-service.mdc:0-0
Timestamp: 2025-06-24T09:37:14.531Z
Learning: Use the PrismaService for all database operations and wrap multiple operations in transactions for atomicity.
services/workflows-service/src/collection-flow/services/сollection-flow-utility/collection-flow-utility.module.ts (3)
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/data-migrations.mdc:0-0
Timestamp: 2025-06-24T09:35:54.963Z
Learning: In Ballerine's workflow migration scripts (TypeScript), always establish the relationship between workflow definitions and UI definitions solely through the 'workflowDefinitionId' field in the UiDefinition model; do not create a separate junction table or relation.
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/workflows-service.mdc:0-0
Timestamp: 2025-06-24T09:37:14.531Z
Learning: Avoid circular dependencies in all modules to prevent runtime errors and maintain code clarity.
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/workflows-service.mdc:0-0
Timestamp: 2025-06-24T09:37:14.531Z
Learning: Imports in TypeScript files should be grouped in the following order with blank lines between groups: Node.js built-in modules, external npm packages, internal modules using @/ alias, and relative imports.
services/workflows-service/src/document/document.service.ts (2)
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/workflows-service.mdc:0-0
Timestamp: 2025-06-24T09:37:14.531Z
Learning: Use the PrismaService for all database operations and wrap multiple operations in transactions for atomicity.
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/data-migrations.mdc:0-0
Timestamp: 2025-06-24T09:35:54.963Z
Learning: In Ballerine's workflow migration scripts (TypeScript), always establish the relationship between workflow definitions and UI definitions solely through the 'workflowDefinitionId' field in the UiDefinition model; do not create a separate junction table or relation.
services/workflows-service/src/collection-flow/services/сollection-flow-utility/collection-flow-utility.service.ts (1)
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/data-migrations.mdc:0-0
Timestamp: 2025-06-24T09:35:54.963Z
Learning: In Ballerine's workflow migration scripts (TypeScript), always establish the relationship between workflow definitions and UI definitions solely through the 'workflowDefinitionId' field in the UiDefinition model; do not create a separate junction table or relation.
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Analyze (javascript)
- GitHub Check: test_linux
- GitHub Check: build (ubuntu-latest)
- GitHub Check: format
- GitHub Check: lint
🔇 Additional comments (15)
services/workflows-service/prisma/data-migrations (1)
1-1: Review new migrations for schema diffs and conventionsI’ve inspected the incoming data-migration scripts and found:
- No occurrences of
UiDefinitionorworkflowDefinitionId(so UI definitions aren’t being referenced or rerouted).- No calls to
PrismaService.$transaction()(which suggests there are no multi-statement data fixes present).Next steps before merging:
- Run a schema diff against production to catch any breaking changes:
prisma migrate diff \ --from-provider postgresql --from-url "$PROD_DATABASE_URL" \ --to-provider postgresql --to-url "$PRISMA_SCHEMA" \ --script- If any data-migration script performs multiple consecutive operations, wrap them in a single
PrismaService.$transaction()call for atomicity.services/workflows-service/src/document/document.module.ts (2)
13-13: LGTM!Clean integration of the utility module into the document module.
23-23: LGTM!Proper addition to the imports array following NestJS conventions.
services/workflows-service/src/collection-flow/collection-flow.module.ts (2)
52-52: LGTM!Proper import of the utility module into the collection flow module.
71-71: LGTM!Consistent integration following NestJS module patterns.
services/workflows-service/src/collection-flow/services/сollection-flow-utility/collection-flow-utility.service.ts (2)
15-36: LGTM! Solid error handling logic.The method correctly:
- Fetches workflow definition
- Attempts to get UI definition for collection flow
- Returns false for P2025 (not found) errors
- Rethrows other errors
The use of
isPrismaExceptionutility and specific P2025 error code handling is appropriate.
9-13: Proper dependency injection with circular dependency handling.Good use of
forwardRefto handle the circular dependency withWorkflowService.services/workflows-service/src/collection-flow/services/collection-flow-state.service.ts (3)
40-40: LGTM: Clean import additionThe import of
CollectionFlowUtilityServiceis properly added and follows the existing import organization.
52-52: LGTM: Proper dependency injectionThe service is correctly injected into the constructor following the established pattern.
64-72: LGTM: Excellent defensive programming patternThe early return for unsupported collection flow states effectively prevents exceptions and aligns with the PR objective. The
nullreturn value is appropriate for optional collection flow functionality.This implementation follows a clean guard clause pattern that:
- Prevents downstream processing when collection flow isn't supported
- Returns a clear
nullvalue indicating absence of collection flow state- Maintains backward compatibility for existing callers
services/workflows-service/src/document/document.service.ts (5)
45-48: LGTM: Standard Prisma utility importsThe transaction utilities are properly imported and align with the learning about using PrismaService for database operations.
51-51: LGTM: Consistent service importThe
CollectionFlowUtilityServiceimport follows the same pattern as the other file.
64-64: LGTM: Proper dependency injectionThe service injection maintains consistency with the established constructor pattern.
813-828: Excellent refactoring with defensive patternThis change demonstrates several good practices:
- DRY principle: Extracts
defaultTrackerItemsto eliminate duplication- Early return: Prevents unnecessary processing for unsupported collection flows
- Consistent structure: The default return matches the expected tracker format
The defensive check aligns perfectly with the PR objective to fix exceptions on unsupported flows.
841-841: LGTM: Consistent use of extracted constantUsing the extracted
defaultTrackerItemsconstant eliminates code duplication and improves maintainability.
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.
Critical: Fix directory name with Cyrillic character.
The directory name contains a Cyrillic 'с' instead of Latin 'c' in "сollection-flow-utility". This can cause serious issues with:
- File system operations on different OS
- Git operations and version control
- Developer tools and IDEs
- Build processes
Rename the directory from сollection-flow-utility to collection-flow-utility (using Latin 'c').
The module structure itself is correct with proper handling of circular dependencies using forwardRef.
🤖 Prompt for AI Agents
In
services/workflows-service/src/collection-flow/services/сollection-flow-utility/collection-flow-utility.module.ts
lines 1 to 16, the directory name "сollection-flow-utility" uses a Cyrillic 'с'
instead of a Latin 'c', which can cause cross-platform and tooling issues.
Rename the directory to use the Latin 'c' as "collection-flow-utility" and
update all related import paths accordingly to ensure consistency and avoid
errors.
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.
Critical: Fix directory name with Cyrillic character.
Same issue as the module file - the directory name contains a Cyrillic 'с' instead of Latin 'c' in "сollection-flow-utility".
Rename the directory from сollection-flow-utility to collection-flow-utility (using Latin 'c').
🤖 Prompt for AI Agents
In
services/workflows-service/src/collection-flow/services/сollection-flow-utility/collection-flow-utility.service.ts
lines 1 to 37, the directory name "сollection-flow-utility" contains a Cyrillic
'с' instead of a Latin 'c'. Rename the directory to "collection-flow-utility"
using the Latin 'c' to fix the character encoding issue and ensure proper module
resolution.
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
services/workflows-service/src/common/is-prisma-exception/is-prisma-exception.ts (1)
192-193: Type guard implementation is correct but could be more robust.The current implementation only validates the presence of a
codeproperty with a valid Prisma error code. Consider enhancing the validation to ensure it's actually aPrismaClientKnownRequestErrorinstance.Here's a more robust implementation:
-export const isPrismaException = (value: unknown): value is PrismaClientKnownRequestError => - isType(z.object({ code: z.enum(ALL_PRISMA_ERROR_CODES) }))(value); +export const isPrismaException = (value: unknown): value is PrismaClientKnownRequestError => + value instanceof PrismaClientKnownRequestError && + isType(z.object({ code: z.enum(ALL_PRISMA_ERROR_CODES) }))(value);This ensures both the structure and instance type are validated, providing better type safety.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
services/workflows-service/src/common/is-prisma-exception/is-prisma-exception.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
PR: ballerine-io/ballerine#0
File: .cursor/rules/workflows-service.mdc:0-0
Timestamp: 2025-06-24T09:37:14.531Z
Learning: Use the PrismaService for all database operations and wrap multiple operations in transactions for atomicity.
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: build (ubuntu-latest)
- GitHub Check: Analyze (javascript)
- GitHub Check: format
- GitHub Check: spell_check
- GitHub Check: test_linux
- GitHub Check: lint
🔇 Additional comments (1)
services/workflows-service/src/common/is-prisma-exception/is-prisma-exception.ts (1)
1-3: LGTM!The imports are appropriate and necessary for the utility function implementation.
| const ALL_PRISMA_ERROR_CODES = [ | ||
| // Authentication failed | ||
| 'P1000', | ||
| // Unable to connect to database | ||
| 'P1001', | ||
| // Database server connection timed out | ||
| 'P1002', | ||
| // Database does not exist | ||
| 'P1003', | ||
| // Operations timed out | ||
| 'P1008', | ||
| // Database already exists | ||
| 'P1009', | ||
| // User access denied | ||
| 'P1010', | ||
| // Error starting transaction | ||
| 'P1011', | ||
| // Validation error | ||
| 'P1012', | ||
| // Preview feature not enabled | ||
| 'P1013', | ||
| // Underlying kind mismatch | ||
| 'P1014', | ||
| // Prisma extension error | ||
| 'P1015', | ||
| // Engine data loading error | ||
| 'P1016', | ||
| // Server closed connection | ||
| 'P1017', | ||
|
|
||
| // Query Engine (P2xxx) - Query execution and data validation errors | ||
| // Input value too long | ||
| 'P2000', | ||
| // Record does not exist | ||
| 'P2001', | ||
| // Unique constraint violation | ||
| 'P2002', | ||
| // Foreign key constraint violation | ||
| 'P2003', | ||
| // Constraint violation | ||
| 'P2004', | ||
| // Value invalid for type | ||
| 'P2005', | ||
| // Field value null violation | ||
| 'P2006', | ||
| // Data validation error | ||
| 'P2007', | ||
| // Failed to parse query | ||
| 'P2008', | ||
| // Failed to validate query | ||
| 'P2009', | ||
| // Raw query error | ||
| 'P2010', | ||
| // Null constraint violation | ||
| 'P2011', | ||
| // Missing required value | ||
| 'P2012', | ||
| // Missing required argument | ||
| 'P2013', | ||
| // Change violates relation | ||
| 'P2014', | ||
| // Related record not found | ||
| 'P2015', | ||
| // Query interpretation error | ||
| 'P2016', | ||
| // Records not connected | ||
| 'P2017', | ||
| // Required connected records not found | ||
| 'P2018', | ||
| // Input error | ||
| 'P2019', | ||
| // Value out of range | ||
| 'P2020', | ||
| // Table does not exist | ||
| 'P2021', | ||
| // Column does not exist | ||
| 'P2022', | ||
| // Inconsistent column data | ||
| 'P2023', | ||
| // Query execution timed out | ||
| 'P2024', | ||
| // Operation failed | ||
| 'P2025', | ||
| // Unsupported feature | ||
| 'P2026', | ||
| // Multiple errors | ||
| 'P2027', | ||
| // Transaction API error | ||
| 'P2028', | ||
| // Query batch error | ||
| 'P2029', | ||
| // Explicit transaction required | ||
| 'P2030', | ||
| // Transaction rolled back | ||
| 'P2031', | ||
| // Number out of range | ||
| 'P2033', | ||
| // Transaction timeout | ||
| 'P2034', | ||
| // Invalid transaction state | ||
| 'P2035', | ||
| // Transaction rollback error | ||
| 'P2036', | ||
| // Transaction commit error | ||
| 'P2037', | ||
|
|
||
| // Schema Engine (P3xxx) - Schema and migration errors | ||
| // Failed to create database | ||
| 'P3000', | ||
| // Migration possible data loss | ||
| 'P3001', | ||
| // Migration required | ||
| 'P3002', | ||
| // Migration format error | ||
| 'P3003', | ||
| // Migration create error | ||
| 'P3004', | ||
| // Migration apply error | ||
| 'P3005', | ||
| // Migration name required | ||
| 'P3006', | ||
| // Migration already exists | ||
| 'P3007', | ||
| // Migration not found | ||
| 'P3008', | ||
| // Migrate command error | ||
| 'P3009', | ||
| // Migration squash error | ||
| 'P3010', | ||
| // Migration rolled back | ||
| 'P3011', | ||
| // Missing migration file | ||
| 'P3012', | ||
| // Conflicting migrations | ||
| 'P3013', | ||
| // Migrations list error | ||
| 'P3014', | ||
| // Could not find migration | ||
| 'P3015', | ||
| // Migration verification error | ||
| 'P3016', | ||
| // Migration execution error | ||
| 'P3017', | ||
| // Migration manifest error | ||
| 'P3018', | ||
| // Migration script error | ||
| 'P3019', | ||
| // Migration history error | ||
| 'P3020', | ||
| // Migration history conflict | ||
| 'P3021', | ||
| // Failed to parse schema | ||
| 'P3022', | ||
|
|
||
| // DB Pull (P4xxx) - Database introspection errors | ||
| // Introspection error | ||
| 'P4000', | ||
| // Detection conflict | ||
| 'P4001', | ||
| // Introspection validation error | ||
| 'P4002', | ||
|
|
||
| // Accelerate (P5xxx/P6xxx) - Performance and optimization errors | ||
| // Invalid connection string | ||
| 'P5011', | ||
| // Engine version mismatch | ||
| 'P6000', | ||
| // Migration pending | ||
| 'P6001', | ||
| // Engine not started | ||
| 'P6002', | ||
| // Engine timeout | ||
| 'P6003', | ||
| // Engine crashed | ||
| 'P6004', | ||
| // Engine not found | ||
| 'P6005', | ||
| // Engine start error | ||
| 'P6006', | ||
| // Engine protocol error | ||
| 'P6008', | ||
| // Engine file error | ||
| 'P6009', | ||
| // Engine binary error | ||
| 'P6010' | ||
| ] as const; |
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.
💡 Verification agent
🧩 Analysis chain
Comprehensive error code coverage looks good.
The list of Prisma error codes is well-organized and categorized. The comments provide clear context for each category of errors, making the code maintainable and understandable.
However, let's verify that this list includes all current Prisma error codes:
🌐 Web query:
What are all the official Prisma error codes as of 2024? Please provide a comprehensive list including P1xxx, P2xxx, P3xxx, P4xxx, P5xxx, and P6xxx categories.
💡 Result:
As of 2024, Prisma defines a comprehensive set of error codes to help developers diagnose and resolve issues effectively. These error codes are categorized as follows:
Common Errors:
- P1000: Authentication failed against the database server.
- P1001: Can't reach the database server at the specified host and port.
- P1002: Connection to the database server timed out.
- P1003: Database does not exist at the specified path or server.
- P1008: Operation timed out after a specified duration.
- P1009: Database already exists on the server.
- P1010: User was denied access to the database.
- P1011: Error opening a TLS connection.
- P1012: Schema validation error.
- P1013: Invalid database connection string.
- P1014: Underlying model for a specified model does not exist.
- P1015: Unsupported database version.
- P1016: Incorrect parameters provided.
- P1017: Server has closed the connection.
Prisma Client (Query Engine) Errors:
- P2000: Provided value for the column is too long.
- P2001: Record searched for does not exist.
- P2002: Unique constraint failed.
- P2003: Foreign key constraint failed.
- P2004: A constraint failed on the database.
- P2005: Stored value is invalid for the field's type.
- P2006: Provided value for the field is not valid.
- P2007: Data validation error.
- P2008: Failed to parse the query.
- P2009: Failed to validate the query.
- P2010: Raw query failed.
- P2011: Null constraint violation.
- P2012: Missing a required value.
- P2013: Missing a required argument.
- P2014: Change would violate the required relation.
- P2015: Related record could not be found.
- P2016: Query interpretation error.
- P2017: Records for relation are not connected.
- P2018: Required connected records were not found.
- P2019: Input error.
- P2020: Value out of range for the type.
- P2021: Table does not exist in the current database.
- P2022: Column does not exist in the current database.
- P2023: Inconsistent column data.
- P2024: Timed out fetching a new connection from the pool.
- P2025: Operation failed because it depends on one or more records that were required but not found.
- P2026: Current database provider doesn't support a feature that the query used.
- P2027: Multiple errors occurred on the database during query execution.
- P2028: Transaction API error.
- P2030: Cannot find a fulltext index to use for the search.
- P2031: Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set.
- P2033: Number used in the query does not fit into a 64-bit signed integer.
- P2034: Transaction failed due to a write conflict or a deadlock.
- P2035: Assertion violation on the database.
- P2036: Error in external connector.
- P2037: Too many database connections opened.
Prisma Migrate (Schema Engine) Errors:
- P3000: Failed to create database.
- P3001: Migration possible with destructive changes and possible data loss.
- P3002: The attempted migration was rolled back.
- P3003: The format of migrations changed; saved migrations are no longer valid.
- P3004: The database is a system database; it should not be altered with Prisma Migrate.
- P3005: The database schema is not empty.
- P3006: Migration failed to apply cleanly to the shadow database.
- P3007: Some of the requested preview features are not yet allowed in schema engine.
- P3008: The migration is already recorded as applied in the database.
- P3009: Found failed migrations in the target database; new migrations will not be applied.
- P3010: The name of the migration is too long.
- P3011: Migration cannot be rolled back because it was never applied to the database.
- P3012: Migration cannot be rolled back because it is not in a failed state.
- P3013: Datasource provider arrays are no longer supported in migrate.
- P3014: Prisma Migrate could not create the shadow database.
- P3015: Could not find the migration file.
- P3016: The fallback method for database resets failed.
- P3017: The migration could not be found.
- P3018: A migration failed to apply.
- P3019: The datasource provider specified in your schema does not match the one specified in the migration lock.
- P3020: The automatic creation of shadow databases is disabled on Azure SQL.
- P3021: Foreign keys cannot be created on this database.
- P3022: Direct execution of DDL SQL statements is disabled on this database.
Prisma Accelerate Errors:
- P6000: Generic error to catch all other errors.
- P6001: The URL is malformed; for instance, it does not use the
prisma://protocol. - P6002: The API Key in the connection string is invalid.
- P6003: The included usage of the current plan has been exceeded.
- P6004: The global timeout of Accelerate has been exceeded.
- P6005: The user supplied invalid parameters.
- P6006: The chosen Prisma version is not compatible with Accelerate.
- P6008: The engine failed to start.
- P6009: The global response size limit of Accelerate has been exceeded.
- P6010: Your Accelerate project is disabled.
- P5011: This error indicates that the request volume exceeded.
For a detailed explanation of each error code, refer to the Prisma Documentation.
Synchronize Prisma error code comments with official documentation
The list covers all current Prisma error codes, but many comment descriptions are outdated or inaccurate. Please update the in-code comments to match the official Prisma v4 error reference.
Affected locations (services/workflows-service/src/common/is-prisma-exception/is-prisma-exception.ts, lines 5–190):
- Common Errors (P1011–P1017): replace generic/mismatched comments (e.g. P1011 “Error starting transaction”) with the exact descriptions from https://www.prisma.io/docs/orm/reference/error-reference
- Query Engine Errors:
- P2024, P2025, P2026, P2027: expand to full official wording
- P2029: confirm or remove (not listed in the 2024 docs)
- P2030–P2037: update all comments to the official definitions
- (Optional) Migrate (P3000–P3022), DB Pull (P4000–P4002), and Accelerate (P5011, P6000–P6010) comments should likewise be aligned with the docs
Example diff:
- 'P1011', // Error starting transaction
+ 'P1011', // Error opening a TLS connectionCommittable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In
services/workflows-service/src/common/is-prisma-exception/is-prisma-exception.ts
between lines 5 and 190, the comments describing Prisma error codes are outdated
or inaccurate. Update all comment descriptions for error codes P1011 to P1017,
P2024 to P2027, P2030 to P2037, and optionally P3000 to P3022, P4000 to P4002,
and P5011, P6000 to P6010 to exactly match the official Prisma v4 error
reference documentation at
https://www.prisma.io/docs/orm/reference/error-reference. Remove or confirm the
presence of P2029 if it is not listed in the official docs. Replace generic or
mismatched comments with the precise official wording for each error code.
…cleaned code
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Chores