fix(storage): #106.5 — serve_blob בודק קיום ב-S3 ספציפית (לא dual disk-OR-S3) #201

Merged
chaim merged 1 commits from worktree-serve-blob-s3-existence-fix into main 2026-06-11 18:09:06 +00:00
Owner

באג שהתגלה ב-pre-flight ל-dual

DualBackend.exists() מחזיר True אם הקובץ על הדיסק או ב-S3. serve_blob בדק backend.exists() ואז הנפיק presigned — כך שתחת dual, קובץ שקיים רק בדיסק (mirror שנכשל / מחוץ לסט-ההגירה) היה מקבל redirect ל-presigned-URL שמחזיר 404 מ-MinIO, במקום fallback-לדיסק.

תיקון

serve_blob בודק קיום ב-S3 ספציפית: s3 = getattr(backend, "s3", backend) (DualBackend.s3, או ה-S3Backend עצמו תחת s3) — כך שקובץ disk-only נופל ל-FileResponse אמיתי. תואם-לאחור (filesystem/s3 → getattr מחזיר את ה-backend עצמו).

Invariants

  • INV-STG6 — presigned רק כשהאובייקט באמת ב-S3.
  • INV-G10 — אפס שינוי-התנהגות תחת filesystem.

בדיקות

6 (2 חדשות): test_dual_probes_s3_subbackend_not_generic_exists (disk-only → FileResponse, לא redirect שבור) + test_dual_in_s3_uses_s3_subbackend. עוברות. py_compile OK.

🤖 Generated with Claude Code

## באג שהתגלה ב-pre-flight ל-dual `DualBackend.exists()` מחזיר `True` אם הקובץ על **הדיסק או** ב-S3. `serve_blob` בדק `backend.exists()` ואז הנפיק presigned — כך שתחת `dual`, קובץ **שקיים רק בדיסק** (mirror שנכשל / מחוץ לסט-ההגירה) היה מקבל redirect ל-presigned-URL ש**מחזיר 404 מ-MinIO**, במקום fallback-לדיסק. ## תיקון `serve_blob` בודק קיום ב-**S3 ספציפית**: `s3 = getattr(backend, "s3", backend)` (DualBackend.s3, או ה-S3Backend עצמו תחת `s3`) — כך שקובץ disk-only נופל ל-`FileResponse` אמיתי. תואם-לאחור (filesystem/s3 → `getattr` מחזיר את ה-backend עצמו). ## Invariants - **INV-STG6** — presigned רק כשהאובייקט **באמת** ב-S3. - **INV-G10** — אפס שינוי-התנהגות תחת `filesystem`. ## בדיקות 6 (2 חדשות): `test_dual_probes_s3_subbackend_not_generic_exists` (disk-only → FileResponse, **לא** redirect שבור) + `test_dual_in_s3_uses_s3_subbackend`. עוברות. py_compile OK. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-11 18:08:59 +00:00
fix(storage): #106.5 — serve_blob probes S3 sub-backend, not dual disk-OR-S3 exists
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 6s
6359363f13
באג-אינטראקציה שהתגלה לפני ה-flip ל-dual: DualBackend.exists() מחזיר True אם הקובץ על
**הדיסק או** ב-S3. serve_blob בדק backend.exists() ואז הנפיק presigned — כך שתחת dual,
קובץ שקיים-רק-בדיסק (mirror שנכשל / מחוץ לסט-ההגירה) היה מקבל redirect ל-presigned-URL
שמחזיר 404 מ-MinIO, במקום fallback-לדיסק.

תיקון: serve_blob בודק קיום ב-**S3 ספציפית** — `s3 = getattr(backend, "s3", backend)`
(DualBackend.s3, או ה-S3Backend עצמו תחת s3) — כך שקובץ disk-only נופל ל-FileResponse
אמיתי. תואם-לאחור ל-filesystem/s3 (getattr מחזיר את ה-backend עצמו).

invariants: INV-STG6 (presigned רק כשהאובייקט באמת ב-S3) · INV-G10 (אפס שינוי תחת filesystem).
tests: 6 (2 חדשות — dual מ-S3-sub-backend present→redirect / absent→disk-fallback). py_compile OK.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
chaim merged commit 0a45fab4ee into main 2026-06-11 18:09:06 +00:00
chaim deleted branch worktree-serve-blob-s3-existence-fix 2026-06-11 18:09:06 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ezer-mishpati/legal-ai#201