Commit c5502e7
committed
fix(telegram): guard unsupported attachment type with ValidationError (coderabbit)
Addresses CodeRabbit's CHANGES_REQUESTED on #119. `ATTACHMENT_UPLOADS[attachment.type]`
raised a bare `KeyError` for any `attachment.type` outside the supported set.
`Attachment.type` is a `Literal`, but Python does not enforce Literals at
runtime, so an untyped/dynamic caller can supply an out-of-set value. Guard
the lookup and raise a `ValidationError` naming the bad type and the supported
set, consistent with the other validation paths in `send_attachment`.
New `test_rejects_unsupported_attachment_type` is load-bearing — reverting the
guard makes the call raise `KeyError` (not `ValidationError`) and the test fails.
https://claude.ai/code/session_01FyMxQn2BEAzmwKS1GZczKj1 parent 262667c commit c5502e7
2 files changed
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1902 | 1902 | | |
1903 | 1903 | | |
1904 | 1904 | | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
1905 | 1910 | | |
1906 | 1911 | | |
1907 | 1912 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
400 | 426 | | |
401 | 427 | | |
402 | 428 | | |
| |||
0 commit comments