-
Notifications
You must be signed in to change notification settings - Fork 264
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // eslint-disable-next-line import/no-cycle | ||
| import { WorkflowModule } from '@/workflow/workflow.module'; | ||
| import { forwardRef, Module } from '@nestjs/common'; | ||
| import { CollectionFlowUtilityService } from './collection-flow-utility.service'; | ||
| import { UiDefinitionModule } from '@/ui-definition/ui-definition.module'; | ||
|
|
||
| @Module({ | ||
| imports: [ | ||
| // eslint-disable-next-line import/no-cycle | ||
| forwardRef(() => WorkflowModule), | ||
| UiDefinitionModule, | ||
| ], | ||
| providers: [CollectionFlowUtilityService], | ||
| exports: [CollectionFlowUtilityService], | ||
| }) | ||
| export class CollectionFlowUtilityModule {} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { isPrismaException } from '@/common/is-prisma-exception/is-prisma-exception'; | ||
| import { TProjectIds } from '@/types'; | ||
| import { UiDefinitionService } from '@/ui-definition/ui-definition.service'; | ||
| import { WorkflowService } from '@/workflow/workflow.service'; | ||
| import { forwardRef, Inject, Injectable } from '@nestjs/common'; | ||
|
|
||
| @Injectable() | ||
| export class CollectionFlowUtilityService { | ||
| constructor( | ||
| @Inject(forwardRef(() => WorkflowService)) | ||
| protected readonly workflowService: WorkflowService, | ||
| protected readonly uiDefinitionService: UiDefinitionService, | ||
| ) {} | ||
|
|
||
| async isCollectionFlowStateSupported(workflowId: string, projectIds: TProjectIds) { | ||
| const workflowDefinition = await this.workflowService.getWorkflowByIdWithRelations( | ||
| workflowId, | ||
| projectIds, | ||
| ); | ||
|
|
||
| try { | ||
| await this.uiDefinitionService.getByWorkflowDefinitionId( | ||
| workflowDefinition.workflowDefinitionId, | ||
| 'collection_flow', | ||
| projectIds, | ||
| ); | ||
|
|
||
| return true; | ||
| } catch (error) { | ||
| if (isPrismaException(error) && error.code === 'P2025') { | ||
| return false; | ||
| } | ||
|
|
||
| throw error; | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+1
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| import { isType } from '@ballerine/common'; | ||
| import { PrismaClientKnownRequestError } from '@prisma/client/runtime'; | ||
| import { z } from 'zod'; | ||
|
|
||
| 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; | ||
|
Comment on lines
+5
to
+190
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainComprehensive 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: 💡 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:
Prisma Client (Query Engine) Errors:
Prisma Migrate (Schema Engine) Errors:
Prisma Accelerate Errors:
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):
Example diff: - 'P1011', // Error starting transaction
+ 'P1011', // Error opening a TLS connection
🤖 Prompt for AI Agents |
||
|
|
||
| export const isPrismaException = (value: unknown): value is PrismaClientKnownRequestError => | ||
| isType(z.object({ code: z.enum(ALL_PRISMA_ERROR_CODES) }))(value); | ||
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:
Rename the directory from
сollection-flow-utilitytocollection-flow-utility(using Latin 'c').The module structure itself is correct with proper handling of circular dependencies using
forwardRef.🤖 Prompt for AI Agents