{"record":{"id":"408608510174829a","repo":"Tencent/WeKnora","slug":"parse-document-w","errorCode":null,"errorMessage":"parse document: %w","messagePattern":"parse document: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/temporary_document.go","lineNumber":403,"sourceCode":"\n\tparserEngine := strings.TrimSpace(options.ParserEngine)\n\tif parserEngine == \"auto\" {\n\t\tparserEngine = \"\"\n\t}\n\trequest := &types.ReadRequest{\n\t\tFileContent: data, FileName: document.FileName, FileType: strings.TrimPrefix(ext, \".\"),\n\t\tParserEngine: parserEngine,\n\t}\n\tif tenant, ok := ctx.Value(types.TenantInfoContextKey).(*types.Tenant); ok && tenant != nil && tenant.ParserEngineConfig != nil {\n\t\trequest.ParserEngineOverrides = tenant.ParserEngineConfig.ToOverridesMap()\n\t}\n\tdeps := docparser.ReaderDeps{Overrides: request.ParserEngineOverrides, Remote: s.documentReader}\n\tif s.tenantService != nil {\n\t\tdeps.WeKnoraCloudCredentials = s.tenantService.GetWeKnoraCloudCredentials\n\t}\n\treader, err := docparser.NewReader(ctx, parserEngine, strings.TrimPrefix(ext, \".\"), false, deps)\n\tif err != nil {\n\t\treturn \"\", nil, nil, fmt.Errorf(\"parse document: %w\", err)\n\t}\n\tresult, err := reader.Read(ctx, request)\n\tif err != nil {\n\t\treturn \"\", nil, nil, fmt.Errorf(\"parse document: %w\", err)\n\t}\n\t// Capture raw page-image bytes before ResolveAndStore stores/rewrites them,\n\t// so the VLM OCR fallback for scanned documents has bytes to work with.\n\tmaxOCRPages := temporaryDocumentImageOCRMaxPages()\n\tif options.OCRMaxPages > 0 {\n\t\tmaxOCRPages = options.OCRMaxPages\n\t}\n\tpageImages := collectImageBytes(result.ImageRefs, maxOCRPages)\n\timages := make([]types.TemporaryDocumentImage, 0)\n\tif s.imageResolver != nil {\n\t\tupdated, stored, resolveErr := s.imageResolver.ResolveAndStore(\n\t\t\tctx, result, temporarySaveFileService{s.fileService}, document.TenantID,\n\t\t)\n\t\tif resolveErr != nil {","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/temporary_document.go#L385-L421","documentation":"Wraps a failure from docparser.NewReader while constructing a document reader for the given parser engine and extension. Reader construction fails when the engine/format combination is unknown or unsupported (e.g. engine name typo, no reader registered for the extension).","triggerScenarios":"parse → Process on a non-audio document where parserEngine (after trim/auto resolution) plus the trimmed extension yields no registered docparser reader — NewReader returns an error.","commonSituations":"Caller passes an unsupported ParserEngine value (misspelling or engine not compiled in); file extension with no parser available (e.g. unusual binary format); ParserEngineOverrides map references a nonexistent engine.","solutions":["Use a supported ParserEngine value or \"auto\" to let the system pick","Check that the file extension is a supported document format","Verify ParserEngineOverrides entries reference valid engines","Inspect the wrapped error for which engine/format combination failed"],"exampleFix":"// before\ntypes.ParseOptions{ParserEngine: \"ocr-xml\"} // unsupported\n// after\ntypes.ParseOptions{ParserEngine: \"auto\"}","handlingStrategy":"validation","validationCode":"if !docparser.IsSupportedExtension(ext) || !isKnownEngine(opts.ParserEngine) {\n    return errors.New(\"unsupported document format or parser engine\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.HasPrefix(err.Error(), \"parse document:\") {\n        // inspect wrapped cause: unsupported engine/format\n    }\n}","preventionTips":["Use ParserEngine \"auto\" unless a specific engine is required","Keep ParserEngineOverrides limited to verified engine names","Only upload supported file extensions"],"tags":["parsing","document","unsupported-format","reader"],"backgroundTag":"unsupported-file-format","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}