Commit 62c3a11
fix(profile): close PR #87 review nits — math comment + 413 at route
Two actionable observations from the self-review:
1. Comment math was wrong. 10M base64 chars decode to ~7.5 MB binary
(4/3 expansion ratio), not ~5.6 MB. Rewrote the comment to make
the relationship between the body cap and MAX_AVATAR_SIZE
explicit, and to document that the actual binary cap fires below.
2. Decoded-byte size is now checked at the route layer with an
explicit 413, instead of relying on _validate_upload deeper in
the storage service. Two reasons:
- Faster failure: bypassed-frontend callers eat 413 before any
Supabase round-trip.
- Easier route-test reasoning: the contract ("> MAX_AVATAR_SIZE
binary bytes -> 413") lives at the route now.
The storage-layer validate_upload check stays as defence in
depth (and still fires for the surviving multipart-cosmetic
endpoint, which doesn't have the route-level guard).
Added test_decoded_payload_over_size_cap_returns_413 that pins the
contract: a base64 payload that fits the Pydantic max_length but
decodes to MAX_AVATAR_SIZE + 1 bytes is rejected with 413 at the
route, AND `upload_avatar` is never called.
5 avatar tests pass. The other two minor observations from the
review (PR-body wording about the breaking contract change;
URL.createObjectURL heads-up) are not code changes — the first is a
PR-description tweak handled separately, the second is informational
only.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent eac1738 commit 62c3a11
2 files changed
Lines changed: 45 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
269 | 270 | | |
270 | 271 | | |
271 | 272 | | |
272 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
273 | 279 | | |
274 | 280 | | |
275 | 281 | | |
| |||
293 | 299 | | |
294 | 300 | | |
295 | 301 | | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
296 | 314 | | |
297 | 315 | | |
298 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
569 | 595 | | |
570 | 596 | | |
571 | 597 | | |
| |||
0 commit comments