- STATUS/HANDOFF: S113 mega-line + state (Mig 63->64, test 458->477, gotcha 79->80, prod 22->37 NCC, bundle acprMqfB/Ck3BTDdA Run #497) - gotcha #80: ! null-forgiving tren external-parsed data -> NRE an (build 0/0 khong bat; chi test-before-critical bat) - ef-core skill: Mig 64 row + pointer-flush (session-start H1 drift, kill recurring latest-Mig class) - session log 2026-07-12-S113-supplier-import-v2.md Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -1332,6 +1332,16 @@ for h in resp.points: # ← .points không phải iterable trực tiếp
|
||||
|
||||
---
|
||||
|
||||
### 80. `!` null-forgiving trên dữ-liệu-parse-ngoài → NRE ẩn (build 0/0 KHÔNG bắt) (Session 113)
|
||||
|
||||
**Triệu chứng:** Import Excel NCC v2 — dòng thiếu Mã NCC (ô cột-4 trống): preview classify New/draft KHÔNG lỗi + báo "sẽ lưu nháp", nhưng Confirm nổ `NullReferenceException` → **500 CẢ batch** (all-or-nothing → DB 0 ghi). Đúng path R4 lõi "thiếu Mã NCC → nháp" của feature.
|
||||
|
||||
**Cơ chế:** `SupplierExcelImportService.NewSupplier` gán `Code = r.Code!.Trim()`. Parser (`ReadRaw`) trả `null` cho ô trống (KHÔNG phải `""`). Toán tử `!` (null-forgiving) TẮT cảnh-báo nullable của compiler → **build 0 warn / 0 err** dù có mìn. Sibling `entity.IsPublic = !string.IsNullOrWhiteSpace(row.Code)` null-safe nhưng `NewSupplier` thì KHÔNG. Empty-string `""` chạy OK; chỉ `null` nổ — và FE round-trip ô blank thành JSON `null` (không phải `""`) → reachable đường-thường.
|
||||
|
||||
**Fix:** `Code = (r.Code ?? string.Empty).Trim()` → null + "" đồng nhất → Code="" + IsPublic=false (nháp, ẩn khỏi filtered-unique `[Code]<>''`). **Quy tắc:** `!` null-forgiving trên dữ-liệu-parse-từ-ngoài (Excel/JSON/form-input) = MÌN — dùng `?? default` chứ KHÔNG `!`. Build-0/0 KHÔNG bảo-đảm null-safety khi có `!` che. Chỉ **test-before-critical** bắt được (test-specialist viết characterization-test reproduce NRE → em-main fix prod → flip test sang NotThrow+draft). Liên-quan #73 (absolute-set null-clobber).
|
||||
|
||||
---
|
||||
|
||||
## Checklist debug bug mới
|
||||
|
||||
1. Build pass không? → fail → check using + package version compat
|
||||
|
||||
Reference in New Issue
Block a user