UpdateTaskOnDeleteActionCommand - Add logs#17479
Conversation
| isSystemBuild: true, | ||
| }); | ||
| } catch (error) { | ||
| this.logger.debug(`Error details: ${JSON.stringify(error)}`); |
Greptile OverviewGreptile SummaryAdded try-catch error handling around the Critical Issues:
Recommendation: Confidence Score: 1/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Command as UpdateTaskOnDeleteActionCommand
participant Cache as WorkspaceCacheService
participant FieldService as FieldMetadataService
participant Logger as Logger
Command->>Command: runOnWorkspace(workspaceId, options)
Command->>Logger: log("Running UpdateTaskOnDeleteActionCommand...")
Command->>Command: updateTaskRelationOnDeleteAction(workspaceId, isDryRun)
Command->>Cache: getOrRecompute(workspaceId, ['flatFieldMetadataMaps', 'flatObjectMetadataMaps'])
Cache-->>Command: return metadata maps
Command->>Command: find taskTarget object metadata
alt taskTarget not found
Command->>Logger: warn("TaskTarget object metadata not found")
Command-->>Command: return early
end
Command->>Command: find task field in taskTarget
alt task field not found
Command->>Logger: warn("Task field not found")
Command-->>Command: return early
end
alt onDelete already CASCADE
Command->>Logger: log("Task relation already has CASCADE onDelete")
Command-->>Command: return early
end
Command->>Logger: log("Updating task relation onDelete...")
alt not dry run
Command->>FieldService: updateOneField({id, settings, workspaceId})
alt update succeeds
FieldService-->>Command: success
else update fails
FieldService-->>Command: throw error
Command->>Logger: debug("Error details: ...")
Note over Command: Error is caught but execution continues
end
Command->>Logger: log("Successfully updated...")
Note over Command,Logger: This logs success even if update failed!
else dry run
Command->>Logger: log("DRY RUN: Would update...")
end
Command->>Command: deleteOrphanedTaskTargets(workspaceId, isDryRun)
|
| try { | ||
| await this.fieldMetadataService.updateOneField({ | ||
| updateFieldInput: { | ||
| id: taskField.id, | ||
| settings: updatedSettings, | ||
| }, | ||
| workspaceId, | ||
| isSystemBuild: true, | ||
| }); | ||
| } catch (error) { | ||
| this.logger.debug(`Error details: ${JSON.stringify(error)}`); | ||
|
|
||
| throw error; | ||
| } | ||
|
|
||
| this.logger.log( |
There was a problem hiding this comment.
Error is caught and logged but execution continues to log "Successfully updated..." even when the update fails. This creates misleading logs and hides failures. Either rethrow the error, or move the success log inside the try block, or at minimum log an error (not debug) and return early.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/twenty-server/src/database/commands/upgrade-version-command/1-16/1-16-update-task-on-delete-action.command.ts
Line: 129:144
Comment:
Error is caught and logged but execution continues to log "Successfully updated..." even when the update fails. This creates misleading logs and hides failures. Either rethrow the error, or move the success log inside the try block, or at minimum log an error (not debug) and return early.
How can I resolve this? If you propose a fix, please make it concise.| isSystemBuild: true, | ||
| }); | ||
| } catch (error) { | ||
| this.logger.debug(`Error details: ${JSON.stringify(error)}`); |
There was a problem hiding this comment.
logger.debug is too low a level for errors in a migration command. Use logger.error or logger.warn to ensure errors are visible in production logs.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/twenty-server/src/database/commands/upgrade-version-command/1-16/1-16-update-task-on-delete-action.command.ts
Line: 139:139
Comment:
`logger.debug` is too low a level for errors in a migration command. Use `logger.error` or `logger.warn` to ensure errors are visible in production logs.
How can I resolve this? If you propose a fix, please make it concise.|
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:45676 This environment will automatically shut down when the PR is closed or after 5 hours. |
|
Hey @etiennejouan! After you've done the QA of your Pull Request, you can mark it as done here. Thank you! |
No description provided.