Commit 3ea5905
committed
fix(knowledge): parse the stored artifact, not the document's display name
A connector document's `filename` is a display name that deliberately disagrees
with the bytes on disk: the sync engine records the source file's name
(`Report.pdf`) while storing the text the connector already extracted from it
under a `.txt` key, with `mimeType: 'text/plain'`.
`processDocumentAsync` discards the processing filename the sync engine computes
and rebuilds its input from the document row, so the parser was chosen from the
display name and re-parsed extracted text as the source binary. In production
that failed 1,379 SharePoint PDFs with `Invalid PDF structure.` and silently
double-wrapped 364 spreadsheets — those reported `completed`, wrapping a second
fake sheet around the connector's own extraction, because SheetJS accepts almost
any input.
Parser selection now prefers the extension of the object actually fetched,
falling back to the filename/MIME path when the URL is not ours or the key
carries no extension a parser claims. Both ingestion paths are honest under that
rule because `fitStorageKeyName` preserves extensions through truncation: an
upload keys on its original name, a connector document keys on what it stored.
This layer is what covers the stuck-document retry sweep, which rebuilds its own
input from the same display name — the sweep is the path that reprocesses the
already-failed documents, so a fix confined to `processDocumentAsync` would have
left the remediation itself broken.
The defect predates the connectors that expose it: Box fetches Box-side text
representations for `pdf`/`docx`/`xlsx` and stores them under the source name
too, so it was latent there before SharePoint and OneDrive reached binary
formats.
`connectorArtifactFileName` now owns the `.txt` suffix that the parser choice
depends on, so the invariant is structural instead of a convention repeated at
four call sites per function.1 parent 1c69372 commit 3ea5905
4 files changed
Lines changed: 140 additions & 19 deletions
File tree
- apps/sim/lib/knowledge
- connectors
- documents
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
67 | 81 | | |
68 | 82 | | |
69 | 83 | | |
| |||
1657 | 1671 | | |
1658 | 1672 | | |
1659 | 1673 | | |
1660 | | - | |
1661 | | - | |
| 1674 | + | |
| 1675 | + | |
1662 | 1676 | | |
1663 | 1677 | | |
1664 | 1678 | | |
1665 | | - | |
| 1679 | + | |
1666 | 1680 | | |
1667 | 1681 | | |
1668 | 1682 | | |
1669 | 1683 | | |
1670 | | - | |
| 1684 | + | |
1671 | 1685 | | |
1672 | 1686 | | |
1673 | 1687 | | |
| |||
1676 | 1690 | | |
1677 | 1691 | | |
1678 | 1692 | | |
1679 | | - | |
1680 | | - | |
1681 | 1693 | | |
1682 | 1694 | | |
1683 | 1695 | | |
| |||
1718 | 1730 | | |
1719 | 1731 | | |
1720 | 1732 | | |
1721 | | - | |
| 1733 | + | |
1722 | 1734 | | |
1723 | 1735 | | |
1724 | 1736 | | |
| |||
1746 | 1758 | | |
1747 | 1759 | | |
1748 | 1760 | | |
1749 | | - | |
1750 | | - | |
| 1761 | + | |
| 1762 | + | |
1751 | 1763 | | |
1752 | 1764 | | |
1753 | 1765 | | |
1754 | | - | |
| 1766 | + | |
1755 | 1767 | | |
1756 | 1768 | | |
1757 | 1769 | | |
1758 | 1770 | | |
1759 | | - | |
| 1771 | + | |
1760 | 1772 | | |
1761 | 1773 | | |
1762 | 1774 | | |
| |||
1765 | 1777 | | |
1766 | 1778 | | |
1767 | 1779 | | |
1768 | | - | |
1769 | | - | |
1770 | 1780 | | |
1771 | 1781 | | |
1772 | 1782 | | |
| |||
1839 | 1849 | | |
1840 | 1850 | | |
1841 | 1851 | | |
1842 | | - | |
| 1852 | + | |
1843 | 1853 | | |
1844 | 1854 | | |
1845 | 1855 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| |||
841 | 844 | | |
842 | 845 | | |
843 | 846 | | |
844 | | - | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
845 | 850 | | |
846 | 851 | | |
847 | 852 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
2 | 7 | | |
3 | 8 | | |
4 | 9 | | |
| |||
12 | 17 | | |
13 | 18 | | |
14 | 19 | | |
15 | | - | |
16 | | - | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
36 | 41 | | |
37 | 42 | | |
38 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
Lines changed: 73 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
0 commit comments