From fcc9529a208349d568a8f17f6979e9045f8b6a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 3 Oct 2025 12:57:52 +0200 Subject: [PATCH 1/2] Add missing javascript dependency in package.json --- .changes/unreleased/Fixed-20251003-125745.yaml | 6 ++++++ package.json | 1 + 2 files changed, 7 insertions(+) create mode 100644 .changes/unreleased/Fixed-20251003-125745.yaml diff --git a/.changes/unreleased/Fixed-20251003-125745.yaml b/.changes/unreleased/Fixed-20251003-125745.yaml new file mode 100644 index 000000000..ef6ec9882 --- /dev/null +++ b/.changes/unreleased/Fixed-20251003-125745.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Add missing javascript dependency +time: 2025-10-03T12:57:45.693475353+02:00 +custom: + Issue: "" + SchemaChange: No schema change diff --git a/package.json b/package.json index fc50ba29c..a013df3da 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "@tsconfig/node20": "^20.1.4", "@types/dompurify": "^3.0.5", "@types/leaflet": "^1.9.3", + "@vueuse/core": "^13.9.0", "bootstrap-icons": "^1.11.3", "dropzone": "^5.7.6", "es6-promise": "^4.2.8", From f9ad96c78bd057c32f42f0beae03565369f9a3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 3 Oct 2025 13:01:39 +0200 Subject: [PATCH 2/2] Introduce `ConversionWithSameMimeTypeException` for improved error handling in document conversion. - Added the `ConversionWithSameMimeTypeException` to handle cases where document conversion is requested for the same MIME type. - Updated `StoredObjectToPdfConverter` to throw the new exception when encountering such cases. - Enhanced error logging in `PostSendExternalMessageHandler` to capture these specific conversion errors. --- .../unreleased/Fixed-20251003-130249.yaml | 6 ++++++ .../ConversionWithSameMimeTypeException.php | 20 +++++++++++++++++++ .../Service/StoredObjectToPdfConverter.php | 8 +++++--- .../PostSendExternalMessageHandler.php | 5 +++++ 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 .changes/unreleased/Fixed-20251003-130249.yaml create mode 100644 src/Bundle/ChillDocStoreBundle/Exception/ConversionWithSameMimeTypeException.php diff --git a/.changes/unreleased/Fixed-20251003-130249.yaml b/.changes/unreleased/Fixed-20251003-130249.yaml new file mode 100644 index 000000000..b6db3cafc --- /dev/null +++ b/.changes/unreleased/Fixed-20251003-130249.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Add exception handling for conversion of attachment on sending external, when documens are already in pdf +time: 2025-10-03T13:02:49.524835257+02:00 +custom: + Issue: "" + SchemaChange: No schema change diff --git a/src/Bundle/ChillDocStoreBundle/Exception/ConversionWithSameMimeTypeException.php b/src/Bundle/ChillDocStoreBundle/Exception/ConversionWithSameMimeTypeException.php new file mode 100644 index 000000000..06fb4a9ed --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Exception/ConversionWithSameMimeTypeException.php @@ -0,0 +1,20 @@ +getCurrentVersion(); if ($currentVersion->getType() === $newMimeType) { - throw new \UnexpectedValueException('Already at the same mime type'); + throw new ConversionWithSameMimeTypeException($newMimeType); } $content = $this->storedObjectManager->read($currentVersion); diff --git a/src/Bundle/ChillMainBundle/Workflow/Messenger/PostSendExternalMessageHandler.php b/src/Bundle/ChillMainBundle/Workflow/Messenger/PostSendExternalMessageHandler.php index 66888cce6..2e5f74808 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Messenger/PostSendExternalMessageHandler.php +++ b/src/Bundle/ChillMainBundle/Workflow/Messenger/PostSendExternalMessageHandler.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Workflow\Messenger; +use Chill\DocStoreBundle\Exception\ConversionWithSameMimeTypeException; use Chill\DocStoreBundle\Exception\StoredObjectManagerException; use Chill\DocStoreBundle\Service\StoredObjectToPdfConverter; use Chill\MainBundle\Entity\Workflow\EntityWorkflow; @@ -55,6 +56,8 @@ final readonly class PostSendExternalMessageHandler implements MessageHandlerInt $this->storedObjectToPdfConverter->addConvertedVersion($attachment->getProxyStoredObject(), $locale); } catch (StoredObjectManagerException $e) { $this->logger->error('Error converting attachment to PDF', ['backtrace' => $e->getTraceAsString(), 'attachment_id' => $attachment->getId()]); + } catch (ConversionWithSameMimeTypeException $e) { + $this->logger->error('Error converting attachment to PDF: already at the same MIME type', ['backtrace' => $e->getTraceAsString(), 'attachment_id' => $attachment->getId()]); } } @@ -65,6 +68,8 @@ final readonly class PostSendExternalMessageHandler implements MessageHandlerInt $this->storedObjectToPdfConverter->addConvertedVersion($storedObject, $locale); } catch (StoredObjectManagerException $e) { $this->logger->error('Error converting stored object to PDF', ['backtrace' => $e->getTraceAsString(), 'stored_object_id' => $storedObject->getId(), 'workflow_id' => $entityWorkflow->getId()]); + } catch (ConversionWithSameMimeTypeException $e) { + $this->logger->error('Error converting stored object to PDF: already at the same MIME type', ['backtrace' => $e->getTraceAsString(), 'stored_object_id' => $storedObject->getId(), 'workflow_id' => $entityWorkflow->getId()]); } } }