mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 01:08:26 +00:00 
			
		
		
		
	Merge branch 'fix/cancel-stale-workflow-handle-fails-silently' into 'master'
Add consistent LOG_PREFIX and key to CancelStaleWorkflowHandler logs See merge request Chill-Projet/chill-bundles!817
This commit is contained in:
		
							
								
								
									
										6
									
								
								.changes/unreleased/Fixed-20250416-210315.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.changes/unreleased/Fixed-20250416-210315.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| kind: Fixed | ||||
| body: Add consistent log prefix and key to logs when stale workflows are automatically canceled | ||||
| time: 2025-04-16T21:03:15.491889784+02:00 | ||||
| custom: | ||||
|     Issue: "" | ||||
|     SchemaChange: No schema change | ||||
| @@ -25,6 +25,8 @@ use Symfony\Component\Workflow\Transition; | ||||
| #[AsMessageHandler] | ||||
| final readonly class CancelStaleWorkflowHandler | ||||
| { | ||||
|     private const LOG_PREFIX = '[CancelStaleWorkflowHandler] '; | ||||
|  | ||||
|     public function __construct( | ||||
|         private EntityWorkflowRepository $workflowRepository, | ||||
|         private Registry $registry, | ||||
| @@ -40,13 +42,13 @@ final readonly class CancelStaleWorkflowHandler | ||||
|  | ||||
|         $workflow = $this->workflowRepository->find($message->getWorkflowId()); | ||||
|         if (null === $workflow) { | ||||
|             $this->logger->alert('Workflow was not found!', [$workflowId]); | ||||
|             $this->logger->alert(self::LOG_PREFIX.'Workflow was not found!', ['entityWorkflowId' => $workflowId]); | ||||
|  | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         if (false === $workflow->isStaledAt($olderThanDate)) { | ||||
|             $this->logger->alert('Workflow has transitioned in the meantime.', [$workflowId]); | ||||
|             $this->logger->alert(self::LOG_PREFIX.'Workflow has transitioned in the meantime.', ['entityWorkflowId' => $workflowId]); | ||||
|  | ||||
|             throw new UnrecoverableMessageHandlingException('the workflow is not staled any more'); | ||||
|         } | ||||
| @@ -67,14 +69,14 @@ final readonly class CancelStaleWorkflowHandler | ||||
|                     'transitionAt' => $this->clock->now(), | ||||
|                     'transition' => $transition->getName(), | ||||
|                 ]); | ||||
|                 $this->logger->info('EntityWorkflow has been cancelled automatically.', [$workflowId]); | ||||
|                 $this->logger->info(self::LOG_PREFIX.'EntityWorkflow has been cancelled automatically.', ['entityWorkflowId' => $workflowId]); | ||||
|                 $transitionApplied = true; | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (!$transitionApplied) { | ||||
|             $this->logger->error('No valid transition found for EntityWorkflow.', [$workflowId]); | ||||
|             $this->logger->error(self::LOG_PREFIX.'No valid transition found for EntityWorkflow.', ['entityWorkflowId' => $workflowId]); | ||||
|             throw new UnrecoverableMessageHandlingException(sprintf('No valid transition found for EntityWorkflow %d.', $workflowId)); | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user