690601:1816 ADR-032-232 #07
CI / CD Pipeline / build (push) Successful in 5m2s
CI / CD Pipeline / deploy (push) Successful in 4m1s

This commit is contained in:
2026-06-01 18:16:25 +07:00
parent cd2bd5bf19
commit 09505f5793
2 changed files with 35 additions and 3 deletions
+18 -2
View File
@@ -331,6 +331,19 @@ export class OcrService {
}; };
} catch (err: unknown) { } catch (err: unknown) {
const durationMs = Date.now() - startTime; const durationMs = Date.now() - startTime;
// ดึง axios response body detail ออกมาด้วย (เช่น ไม่พบไฟล์: /mnt/uploads/...)
const axiosDetail =
err !== null &&
typeof err === 'object' &&
'response' in err &&
err.response !== null &&
typeof err.response === 'object' &&
'data' in err.response &&
err.response.data !== null &&
typeof err.response.data === 'object' &&
'detail' in err.response.data
? String((err.response.data as { detail: unknown }).detail)
: null;
const cause = const cause =
err instanceof AggregateError && err.errors?.length err instanceof AggregateError && err.errors?.length
? err.errors ? err.errors
@@ -339,6 +352,9 @@ export class OcrService {
: err instanceof Error : err instanceof Error
? err.message ? err.message
: String(err); : String(err);
const fullCause = axiosDetail
? `${cause} — sidecar detail: ${axiosDetail} (sidecarPath: ${sidecarPath})`
: `${cause} (sidecarPath: ${sidecarPath})`;
await this.writeAuditLog({ await this.writeAuditLog({
documentPublicId: input.documentPublicId, documentPublicId: input.documentPublicId,
@@ -347,11 +363,11 @@ export class OcrService {
modelType: 'tesseract', modelType: 'tesseract',
status: AiAuditStatus.FAILED, status: AiAuditStatus.FAILED,
processingTimeMs: durationMs, processingTimeMs: durationMs,
errorMessage: cause, errorMessage: fullCause,
cacheHit: false, cacheHit: false,
}); });
throw new Error(`Tesseract OCR Sidecar failed: ${cause}`); throw new Error(`Tesseract OCR Sidecar failed: ${fullCause}`);
} }
} }
@@ -130,9 +130,25 @@ export class SandboxOcrEngineService {
fallbackUsed: false, fallbackUsed: false,
}; };
} catch (error: unknown) { } catch (error: unknown) {
// ดึง axios response body detail ออกมาด้วย (เช่น ไม่พบไฟล์: /mnt/uploads/...)
const axiosDetail =
error !== null &&
typeof error === 'object' &&
'response' in error &&
error.response !== null &&
typeof error.response === 'object' &&
'data' in error.response &&
error.response.data !== null &&
typeof error.response.data === 'object' &&
'detail' in error.response.data
? String((error.response.data as { detail: unknown }).detail)
: null;
const cause = error instanceof Error ? error.message : String(error); const cause = error instanceof Error ? error.message : String(error);
const fullCause = axiosDetail
? `${cause} — sidecar detail: ${axiosDetail}`
: cause;
this.logger.warn( this.logger.warn(
`Typhoon OCR failed in sandbox, falling back to Tesseract: ${cause}` `Typhoon OCR failed in sandbox, falling back to Tesseract: ${fullCause}`
); );
const fallbackResult = await this.ocrService.detectAndExtract({ const fallbackResult = await this.ocrService.detectAndExtract({