Commit 2396286
Enrich docling-serve error messages with workaround hints (#37)
When a docling-serve response contains a known failure pattern, append
a short actionable hint to the message before it surfaces in the
plugin's toast. Today: one pattern, the Apple-Silicon MPS + float64
RT-DETRv2 bug. Tomorrow: easy to add more patterns to the same table.
A real user hit "HTTP 500: Cannot convert a MPS Tensor to float64 dtype
…" with no recovery path from the toast itself. With this change the
toast also says: "Apple Silicon MPS bug — restart docling-serve with
PYTORCH_ENABLE_MPS_FALLBACK=1 (see README → Troubleshooting)." The
README change in the previous PR (docs/troubleshooting-mps) owns the
long-form explanation; this PR is just the in-app pointer.
Design
- New `src/utils/serverErrorHints.ts` exports a `KNOWN_SERVER_ISSUES`
table (`{id, matches, hint}[]`) and a pure `enrichServerError(message)`
helper. The helper appends one hint per matching entry, separated by
" · ". No match → unchanged message. Predicate throws are swallowed —
a broken pattern must never break error surfacing.
- The MPS pattern matches both "MPS" and "float64" as independent tokens
rather than as a fixed phrase, so it survives reorderings across
docling / transformers / PyTorch versions.
- Wired into convert.ts at the two outbound-error sites:
* parseConvertResponse — non-2xx with body.
* convertAttachmentInner — server-side "failure"/"partial_success".
Both apply the helper just before returning the message that becomes
the toast.
Tests
- New `test/serverErrorHints.test.ts` follows the Goldberg conventions
already in place (3-part names, AAA blocks, BDD assertions, `#cold`
tag, realistic input verbatim from a docling-serve traceback).
- Covers: MPS+float64 match (both orderings), unrelated errors pass
through unchanged, empty input, single-token false-positive cases
(MPS without float64, float64 without MPS — neither triggers).
- Sanity-checks the table itself (every entry has id/matches/hint;
ids are unique).
`npx tsc --noEmit`, `npx eslint .`, `npx prettier --check .`, and
`npm run build` all pass.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c31714a commit 2396286
3 files changed
Lines changed: 75 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
369 | 370 | | |
370 | 371 | | |
371 | 372 | | |
372 | | - | |
| 373 | + | |
| 374 | + | |
373 | 375 | | |
374 | 376 | | |
375 | 377 | | |
| |||
653 | 655 | | |
654 | 656 | | |
655 | 657 | | |
| 658 | + | |
656 | 659 | | |
657 | 660 | | |
658 | | - | |
| 661 | + | |
659 | 662 | | |
660 | 663 | | |
661 | 664 | | |
| |||
| 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 | + | |
Binary file not shown.
0 commit comments