From 4981bcaef26ec858a277b14b800a5e94a20977af Mon Sep 17 00:00:00 2001 From: devinleighsmith Date: Mon, 23 Dec 2024 14:20:52 -0800 Subject: [PATCH] update truncation logic, error handling. --- source/backend/api/Services/DocumentQueueService.cs | 4 ++-- source/backend/api/Services/DocumentService.cs | 5 +++-- .../Models/Concepts/DocumentQueue/DocumentQueueModel.cs | 5 ----- source/backend/scheduler/Services/DocumentQueueService.cs | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/source/backend/api/Services/DocumentQueueService.cs b/source/backend/api/Services/DocumentQueueService.cs index ebfa563d3b..9349c9c368 100644 --- a/source/backend/api/Services/DocumentQueueService.cs +++ b/source/backend/api/Services/DocumentQueueService.cs @@ -252,7 +252,7 @@ public async Task Upload(PimsDocumentQueue documentQueue) databaseDocumentQueue.DocumentQueueStatusTypeCode, response.DocumentExternalResponse.Status); - databaseDocumentQueue.MayanError = $"Failed to upload document, mayan error: {response.DocumentExternalResponse.Message}".Truncate(4000); + databaseDocumentQueue.MayanError = $"Failed to upload document, mayan error: {response.DocumentExternalResponse.Message}"; UpdateDocumentQueueStatus(databaseDocumentQueue, DocumentQueueStatusTypes.MAYAN_ERROR); return databaseDocumentQueue; } @@ -267,7 +267,7 @@ public async Task Upload(PimsDocumentQueue documentQueue) catch (Exception ex) when (ex is BadRequestException || ex is KeyNotFoundException || ex is InvalidDataException || ex is JsonException) { this.Logger.LogError($"Error: {ex.Message}"); - databaseDocumentQueue.MayanError = ex.Message.Truncate(4000); + databaseDocumentQueue.MayanError = ex.Message; UpdateDocumentQueueStatus(databaseDocumentQueue, DocumentQueueStatusTypes.PIMS_ERROR); } return databaseDocumentQueue; diff --git a/source/backend/api/Services/DocumentService.cs b/source/backend/api/Services/DocumentService.cs index 32e7ff9b17..e24344e0cf 100644 --- a/source/backend/api/Services/DocumentService.cs +++ b/source/backend/api/Services/DocumentService.cs @@ -211,7 +211,7 @@ public async Task UploadDocumentSync(DocumentUploadReque public async Task UploadDocumentAsync(DocumentUploadRequest uploadRequest, bool skipExtensionCheck = false) { - this.Logger.LogInformation("Uploading document, do not wait for mayan processing."); + this.Logger.LogInformation("Uploading document, do not wait for mayan processing. documentId: {documentId}", uploadRequest.DocumentId); this.User.ThrowIfNotAuthorized(Permissions.DocumentAdd); ExternalResponse externalResponse = await UploadDocumentAsync(uploadRequest.DocumentTypeMayanId, uploadRequest.File, skipExtensionCheck); @@ -232,7 +232,8 @@ public async Task UploadDocumentAsync(DocumentUploadRequ } else { - this.Logger.LogError("Failed to update associated PIMS document with uploaded Mayan Id."); + this.Logger.LogError("Failed to update associated PIMS document with uploaded Mayan Id. documentId: {documentId}", uploadRequest.DocumentId); + this.Logger.LogDebug("Mayan response: {response}", response.Serialize()); } return response; diff --git a/source/backend/apimodels/Models/Concepts/DocumentQueue/DocumentQueueModel.cs b/source/backend/apimodels/Models/Concepts/DocumentQueue/DocumentQueueModel.cs index bc778b168c..5565a39086 100644 --- a/source/backend/apimodels/Models/Concepts/DocumentQueue/DocumentQueueModel.cs +++ b/source/backend/apimodels/Models/Concepts/DocumentQueue/DocumentQueueModel.cs @@ -56,11 +56,6 @@ public class DocumentQueueModel : BaseAuditModel /// public string MayanError { get; set; } - /// - /// get/set - The actual document, represented as a byte[]. - /// - public byte[] Document { get; set; } - /// /// get/set - The actual document, represented as a byte[]. /// diff --git a/source/backend/scheduler/Services/DocumentQueueService.cs b/source/backend/scheduler/Services/DocumentQueueService.cs index 4716e798fa..c0c6926123 100644 --- a/source/backend/scheduler/Services/DocumentQueueService.cs +++ b/source/backend/scheduler/Services/DocumentQueueService.cs @@ -173,7 +173,7 @@ private DocumentQueueResponseModel HandleDocumentQueueResponse(string httpMethod var currentDocumentQueue = currentDocumentResponse.Result.Payload; _logger.LogError("Received error response from {httpMethodName} for queued document {documentQueueId} status {Status} message: {Message}", httpMethodName, currentDocumentQueue?.Id, response?.Result?.Status, response?.Result?.Message); currentDocumentQueue.DocumentQueueStatusType.Id = DocumentQueueStatusTypes.PIMS_ERROR.ToString(); - currentDocumentQueue.MayanError = $"Document {httpMethodName} failed: {response?.Result?.Message}".Truncate(4000); + currentDocumentQueue.MayanError = $"Document {httpMethodName} failed: {response?.Result?.Message}"; _ = _pimsDocumentQueueRepository.UpdateQueuedDocument(currentDocumentQueue.Id, currentDocumentQueue); }); return new DocumentQueueResponseModel() { DocumentQueueStatus = DocumentQueueStatusTypes.PIMS_ERROR, Message = $"Received error response from {httpMethodName} for queued document {qd?.Id} status {response?.Result?.Status} message: {response?.Result?.Message}" };