fix(ocr): report the actual provider and PPTX failure location
HTTP OCR failures in PPTX parsing were incorrectly labeled as local OCR failures. Report the selected provider and slide/image location, and retain bounded structured server diagnostics with configured-key redaction and log IDs. Preserve existing fallback behavior. Validation: 38 focused tests, typecheck and lint passed. Full test run timed out after 200 seconds. Synthetic service probes reproduced HTTP 500; the server-side failure remains unresolved. Release note: PPTX parsing warnings now identify the actual OCR provider and failed image location, with server diagnostics for troubleshooting.
This commit is contained in:
@@ -553,6 +553,7 @@ export class DocumentParsingService {
|
||||
let extractedCharacters = native.reduce(
|
||||
(total, section) => total + section.content.length, 0
|
||||
)
|
||||
let activeLocator: string | undefined
|
||||
if (imagePages.length > 0) {
|
||||
try {
|
||||
const http = settings.ocrProvider === 'paddleocr-vl' ? this.httpProvider(operation) : undefined
|
||||
@@ -564,6 +565,7 @@ export class DocumentParsingService {
|
||||
for (const [index, image] of page.images.entries()) {
|
||||
ensureNotAborted(signal)
|
||||
const locator = `幻灯片 ${page.pageNumber} · 图片 ${index + 1}`
|
||||
activeLocator = locator
|
||||
if (!image.mimeType) {
|
||||
throw new Error(`${locator} 的格式暂不支持 OCR:${extname(image.name)}`)
|
||||
}
|
||||
@@ -611,11 +613,12 @@ export class DocumentParsingService {
|
||||
purpose === 'knowledge-index' ||
|
||||
!native.some((section) => hasUsefulText(section.content))
|
||||
) {
|
||||
if (activeLocator && error instanceof Error) throw new Error(`${activeLocator}:${error.message}`, { cause: error })
|
||||
throw error
|
||||
}
|
||||
return buildPagedDocument(name, native, pages.length, [
|
||||
`本地 OCR 不可用,已保留 PPTX 文本内容:${
|
||||
error instanceof Error ? error.message : '本地 OCR 识别失败'
|
||||
`${settings.ocrProvider === 'paddleocr-vl' ? 'HTTP OCR' : '本地 OCR'} 未完成,已保留 PPTX 文本内容:${activeLocator ? `${activeLocator}:` : ''}${
|
||||
error instanceof Error ? error.message : 'OCR 识别失败'
|
||||
}`.slice(0, 500)
|
||||
], '.pptx')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user