Files
yara724-api/docs/qa-remediation-2026-11-22.md
T
SepehrYahyaee 6b968c0952 fix(workflows): resolve QA blockers and protect case evidence
Fix registrar signing, reviewer re-entry, replacement evidence freshness, owner decision and rating races, multipart objections, vehicle serialization and product reporting.

Validate uploaded media with FFmpeg, serve evidence through expiring signed links, and add targeted regressions plus a dry-run repair for prematurely completed visit cases.
2026-11-22 12:50:22 +03:30

108 lines
9.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# QA remediation — 22 November 2026
Scope: the 28 distinct findings in `QA_REPORT_2026-11-22.txt`,
`QA_REPORT_2026-11-22_CONTINUED.txt`, `QA_REPORT_2026-11-22_EXTENDED.txt`, and
`qa-reports/`. The extended report repeats several continued findings; its
reconciliation supplies IDs 25–28. Changes cover `api`, `ui-user`, and
`ui-expert`. No production database changes or external provider writes were
performed. `rewrite` and `esg` are outside this change.
## Findings and changes
| ID | Resolution | Verification |
| --- | --- | --- |
| 1 | All V3 claim evidence/selection entry points authorize the actor against the case before changing it. | Authorization regression; real foreign-field-expert 403 and positive V3 HTTP filing/capture. |
| 2 | Reviewer assignment distinguishes initial capture from subsequent assessment after maker rejection. An assigned reviewer can acquire an assessment lock again. | HTTP V5: two reject/review cycles, rejection limit, final maker approval. |
| 3 | Both UIs spell rial amounts using locale-independent integer grouping instead of the library recursion triggered by Persian grouping. | Both UI suites; real Persian-locale expert assessment browser. |
| 4 | Added the ordinary-user V6 login page; the incoming blame token survives login redirection. | Real mobile browser link and URL assertion. |
| 5 | Labor-only lines tolerate absent prices; objection payloads omit absent optional monetary values and submission failures remain visible. | Real mobile browser protest form; UI regression suite. |
| 6 | Expired V6 ordinary-user sessions return to `/v6/login`; call-center sessions retain their expert login route. | Role-aware redirect regression. |
| 7 | Multipart nested objection rows become DTO instances and are validated explicitly at the service boundary, including deployments without a global validation pipe. | DTO tests and a real multipart objection through HTTP/MongoDB. |
| 8 | Vehicle subdocuments are serialized before merging resolved identity fields, exposing saved vehicle prices without Mongoose internals or parent documents. | HTTP detail assertions for price and absence of `_doc`/`$__parent`. |
| 9 | Unique-index conflicts during concurrent claim creation become HTTP 409 rather than 500. The database uniqueness constraint remains intact. | Real six-way creation race: one success, five HTTP 409 responses. |
| 10 | Owner claim-detail rejects malformed ObjectIds before querying MongoDB. | Real malformed-ID HTTP 400 control and explicit ID guard. |
| 11 | Upload policy verifies readable media streams and decodes content; text disguised as MP4, wrong media kinds and unreadable content cannot satisfy evidence steps. | Generated image/video/audio controls and corrupt/wrong-kind regression tests. |
| 12 | Shared description handlers enforce the declared weather, road and light enums, including expert form variants. | HTTP invalid-enum rejection without advancement, then valid filing; full API suite. |
| 13 | Expert cards recognize rejected cases and treat rejected/cancelled/stopped cases as view-only. | Expert UI status regressions. |
| 14 | Sheba masking preserves the existing prefix rather than prepending another `IR`. | Response mapping review and full API suite. |
| 15 | Car-body video instructions describe the vehicle and accident scene without requiring two vehicles. | User production build and UI source check. |
| 16 | Evidence is served through a signed, expiring read route, replacing anonymous static serving. Authorized case responses supply links usable by image/video/PDF elements. Arbitrary description text does not mint links. | Bare link 401; signed link 200; altered/expired/cross-path capability tests. See proxy requirements below. |
| 17 | Owner acceptance/rejection uses one conditional atomic update; only its winner records the decision and invokes integrations. Concurrent losing signature records are removed. Signature upload names use UUIDs. | Six-way unit and real MongoDB/HTTP race. |
| 18 | Registrar signatures accept registrar-created cases and follow the same signatures-before-accident-fields order as the shared V2 contract. | HTTP registrar CAR_BODY and THIRD_PARTY through signatures and accident fields. |
| 19 | Instruction-only claim resends display the instruction and offer acknowledgment through the existing endpoint. | Actual mobile browser acknowledgment and persisted queue transition. |
| 20 | Part resends send a stable catalog key/ID, independent of an optional English label. | Client key mapping and HTTP catalog-ID capture. |
| 21 | In-person visits have a pending status, owner instructions and a resumable expert review lock. They no longer imply completion/acceptance. Historical repair is provided separately. | HTTP visit → owner guidance → reassignment → assessment; V4/V5 visit controls; repair dry-run/apply controls. |
| 22 | Expert portfolio queries retain linked blame product type for product filters. | HTTP product counts: both products nonzero and their sum equals the total. |
| 23 | Insurer expert reports use linked blame product types. Missing types for roster-owned claims are resolved in one batch after claim scoping. | Reporting regression, including a linked blame outside the party-insurer list. |
| 24 | Satisfaction rating is written only if no rating exists, in one conditional atomic update. | Six-way concurrent rating regression and real HTTP/MongoDB race: one successful rating. |
| 25 | Versioned user route allowlists use real end anchors instead of requiring a literal `$`. | Browser assertions on five formerly denied routes. |
| 26 | Written blame resends use the text field; voice and document requests render their respective controls. The old duplicate page reuses the shared implementation. | Real browser text-only resend and successful navigation after submission. |
| 27 | Every requested replacement must have a timestamp at or after the current resend request. A partial upload cannot reuse old evidence to finish the request. | Real three-item replacement replay plus timestamp regression; original evidence stays intact. |
| 28 | Legacy top-rated-file normalization preserves root `userRating`, with a fallback for old nested records. | Reporting regression. |
## Verification
Sanitized results: [verification JSON](qa-remediation-2026-11-22-verification.json).
- API: **111 suites, 1,070 tests passed** (`npm test -- --runInBand`).
- API HTTP E2E suite: **26 passed, 4 skipped** (`npm run test:e2e -- --runInBand`).
The four opt-in browser scenarios were not enabled in that runner; independent
browser replays were run separately as described above.
- Both UI regression suites passed (`npm run test:ui`).
- All three production builds passed (`npm run build` in each repository).
- Browser checks used Chromium/Brave, Persian locale, a 390×844 user viewport
and a desktop expert viewport. The UI hardening detector reported no findings
on the changed user-facing views.
- **All 12 flow/product combinations** (v1–v6 × CAR_BODY/THIRD_PARTY) reached
completed claims through filing, capture and assessment. V1/V6 included owner
acceptance; V5 included maker approval. V4/V5 also resumed after a visit.
- Additional HTTP replays used the actual updated Nest process and a disposable
local MongoDB database, synthetic users and generated media. External inquiry,
SMS, AI and Fanavaran requests were intercepted with offline provider fixtures.
These checks do not verify customer WAF/proxy configuration or real provider
acceptance.
## Deployment requirements
Deploy the API and both UIs together, because the pending-visit status and signed
evidence links span their contracts.
1. **Media tools:** the API Dockerfile now installs `ffmpeg`, which includes
`ffprobe`. For deployments outside that Dockerfile, install both binaries in
the API runtime and verify that its service account can execute them. Missing
binaries will correctly reject uploads as unreadable; do not bypass validation.
2. **Evidence proxy:** remove any public Nginx `alias`/`root`/static/CDN rule that
directly exposes the API's `files` directory. Proxy `/files/*` (including its
deployed `/car-damage/api/` prefix, if applicable) to Nest, preserving the
query string and Range headers. A reverse-proxy static bypass would leave the
original anonymous-access issue unresolved. Purge previously cached public
evidence responses. Keep the existing API prefix/rewrite conventions; do not
copy a new `proxy_pass` prefix blindly.
3. **Signing secret:** all API instances serving the same files must share the
existing `JWT_SECRET`. File URLs expire after one hour; reopening/refetching
the authorized case returns fresh URLs. No additional signing secret or
public access switch is introduced. Old cached bare links require a refresh.
4. **Historical visits:** back up the database and preview the narrow repair
from the `api` directory with the intended deployment's environment:
```bash
node scripts/repair-premature-visit-completions.js
# After checking the matched count:
node scripts/repair-premature-visit-completions.js --apply
```
Dry-run is the default. The script only changes `COMPLETED` +
`NEEDS_REVISION` records with an in-person-visit history event and no
submitted assessment, priced parts or recorded owner approvals. It unlocks
review and writes a repair history event. It does not invent an address or
change evidence, payment amounts, signatures or other completed cases.
Dry-run and apply were exercised on synthetic records, with signed/priced
controls left closed. More ambiguous old records need individual review.
5. **Historical races:** overwritten satisfaction ratings or contradictory
owner decisions already recorded before this change cannot be reliably
reconstructed automatically. Review their history and provider submission
records; the code prevents new overlapping writes but does not guess which
old decision was intended.
No commits or pushes are included in this remediation task.