Builds a content-less `failed` document row for a skipped (e.g. oversized) file.
( knowledgeBaseId: string, connectorId: string, connectorType: string, extDoc: ExternalDocument, sourceConfig?: Record<string, unknown> )
| 1092 | |
| 1093 | /** Builds a content-less `failed` document row for a skipped (e.g. oversized) file. */ |
| 1094 | function buildSkippedDocumentRow( |
| 1095 | knowledgeBaseId: string, |
| 1096 | connectorId: string, |
| 1097 | connectorType: string, |
| 1098 | extDoc: ExternalDocument, |
| 1099 | sourceConfig?: Record<string, unknown> |
| 1100 | ) { |
| 1101 | const reason = extDoc.skippedReason ?? 'Document was skipped during sync' |
| 1102 | const tagValues = extDoc.metadata |
| 1103 | ? resolveTagMapping(connectorType, extDoc.metadata, sourceConfig) |
| 1104 | : undefined |
| 1105 | // Connectors put the source size under either `fileSize` or `size`; accept both |
| 1106 | // so the skipped failed row shows the real size instead of 0. |
| 1107 | const rawSize = extDoc.metadata?.fileSize ?? extDoc.metadata?.size |
| 1108 | const fileSize = |
| 1109 | typeof rawSize === 'number' && Number.isFinite(rawSize) ? Math.max(0, Math.trunc(rawSize)) : 0 |
| 1110 | |
| 1111 | return { |
| 1112 | id: generateId(), |
| 1113 | knowledgeBaseId, |
| 1114 | filename: extDoc.title, |
| 1115 | fileUrl: '', |
| 1116 | storageKey: null, |
| 1117 | fileSize, |
| 1118 | mimeType: 'text/plain', |
| 1119 | processingStatus: 'failed', |
| 1120 | processingError: reason, |
| 1121 | enabled: true, |
| 1122 | connectorId, |
| 1123 | externalId: extDoc.externalId, |
| 1124 | contentHash: extDoc.contentHash, |
| 1125 | sourceUrl: extDoc.sourceUrl ?? null, |
| 1126 | ...tagValues, |
| 1127 | uploadedAt: new Date(), |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | /** |
| 1132 | * Records source files that were intentionally not indexed (e.g. they exceed the |
no test coverage detected