Commit 8db77e8
committed
fix(attachments): make PDF screening actually work (pdf-parse v2 API + bundling) (ABCA-745)
PDF attachment screening was silently broken on EVERY channel — live-caught
when the Linear P4 path fetched a PDF and got 'PDF processing is unavailable'.
Two independent bugs, both platform-wide (Jira aws-samples#619 equally affected):
1. API mismatch: code called pdf-parse as the v1 callable `pdfParseFn(buf)`,
but the pinned pdf-parse@^2.4.5 exposes a `PDFParse` CLASS
(`new PDFParse({data}).getText()`). A stale `@types/pdf-parse@^1` + a hand-
written v1 module shim (src/types/pdf-parse.d.ts) made the wrong shape
compile. Rewrote extractPdfText to the v2 class API (first:N page cap,
destroy() teardown); removed both v1 type sources so v2's bundled types apply.
2. Bundling: the Linear + Jira webhook processors bundled pdf-parse with esbuild
(only `externalModules:['@aws-sdk/*']`), mangling its pdfjs/@napi-rs/canvas
deps → 'DOMMatrix is not defined' at import. Added `nodeModules:['pdf-parse']`
so it resolves natively at runtime — matching the TaskApi/orchestrator
attachment-screening bundling that already had the carve-out.
Verified: PDFParse.getText extracts text headless in raw node24 (= the Lambda
runtime). Tests mock the v2 class (ts-jest can't drive pdfjs's ESM worker); the
real extraction is validated on the live deploy. text/csv/etc. unaffected.1 parent 53057b1 commit 8db77e8
7 files changed
Lines changed: 97 additions & 36 deletions
File tree
- cdk
- src
- constructs
- types
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
210 | 219 | | |
211 | 220 | | |
212 | 221 | | |
| |||
258 | 267 | | |
259 | 268 | | |
260 | 269 | | |
261 | | - | |
| 270 | + | |
| 271 | + | |
262 | 272 | | |
263 | 273 | | |
264 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
198 | 207 | | |
199 | 208 | | |
200 | 209 | | |
| |||
262 | 271 | | |
263 | 272 | | |
264 | 273 | | |
265 | | - | |
| 274 | + | |
| 275 | + | |
266 | 276 | | |
267 | 277 | | |
268 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
253 | | - | |
254 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
255 | 260 | | |
256 | | - | |
257 | | - | |
258 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
259 | 265 | | |
260 | 266 | | |
261 | 267 | | |
| |||
268 | 274 | | |
269 | 275 | | |
270 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
271 | 281 | | |
272 | 282 | | |
273 | 283 | | |
274 | 284 | | |
275 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
276 | 289 | | |
277 | | - | |
| 290 | + | |
278 | 291 | | |
279 | 292 | | |
280 | 293 | | |
| |||
291 | 304 | | |
292 | 305 | | |
293 | 306 | | |
| 307 | + | |
| 308 | + | |
294 | 309 | | |
295 | 310 | | |
296 | 311 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
23 | 40 | | |
24 | 41 | | |
25 | 42 | | |
| |||
318 | 335 | | |
319 | 336 | | |
320 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
321 | 351 | | |
322 | 352 | | |
323 | 353 | | |
| |||
360 | 390 | | |
361 | 391 | | |
362 | 392 | | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
369 | 400 | | |
| 401 | + | |
| 402 | + | |
370 | 403 | | |
371 | 404 | | |
372 | 405 | | |
373 | 406 | | |
374 | 407 | | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
375 | 414 | | |
376 | | - | |
377 | | - | |
378 | | - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
379 | 422 | | |
380 | | - | |
| 423 | + | |
381 | 424 | | |
382 | 425 | | |
383 | 426 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments