---
suivi: 1359
date: 2026-08-14
sujet: siwi_dossier_marche_non_cree
chantier: marches_reprise
type: fix
statut: poussé
hash: f6d2e711
fichiers:
  - app/Services/SiwiRepriseActionService.php
  - app/Services/SiwiImportPageService.php
  - resources/js/Pages/SiwiImport/Index.vue
  - database/data/journal_mises_a_jour_post_2026_06_12.php
  - tools/diag/diag_siwi_dossier_marche_1359.php
  - public/build/
  - docs/suivi/SUIVI_1359_siwi_dossier_marche_non_cree.md
---

## PROMPT ENVOYÉ

PHASE 1 diagnostic E2E HECTARE : programme AROME #18 OK SP, marché C2780 →
ERP #200 / MCH-2026-197, case doc cochée, dossier SP marché absent, Docs —.
Question centrale : dossier à la création ou au dépôt ? Bug ou prévu ?
Corriger seulement si cause certaine. Graph non bloquant. Pas de rename SP.

## FICHES LUES

- `#1356` LEÇON : dépôt = bouton programme WEB ; arb CDC à la demande via
  `ensureLotissementCdcMarcheFolders` ; cases UI-only avant.
- `#1353` : jeton app pour `creerDossierMarche` (403 délégué).
- `#1355` : token app bloqué CLI OVH.

## SYNTHÈSE

### Question centrale

| Élément | Comportement code AUJOURD’HUI | Verdict |
|--------|------------------------------|---------|
| Dossier marché SP | Tenté **à la création** (`SiwiRepriseActionService::creerMarche` → `creerDossierMarche`, best-effort try/catch) | Absence après création = **échec** (souvent `null` sans log SIWI avant #1359), pas un report volontaire |
| PDF / Docs | Uniquement via **« Déposer documents »** ; dépôt assure le dossier CDC si besoin | Absence PDF + tag **Docs —** = **comportement prévu** tant que le bouton n’a pas été cliqué |
| Cases « document à déposer » | `doc.selected = true` hardcodé + état local Vue — **aucune persistance**, aucun déclencheur dépôt | **UI trompeuse** (cause certaine de la confusion) |

Choix produit retenu : garder l’appel Graph **non bloquant** à la création + dépôt qui
recrée/assure le dossier à la demande (#1356). Pas d’appel Graph bloquant.

### Correctifs (#1359)

1. Log `siwi.marche_cree_sharepoint_dossier_absent` si `creerDossierMarche` renvoie null
   (avec `lastMarcheFolderCreationResult`).
2. UI : cases désactivées + notice explicite ; tag Docs — documenté ; état dépôt +
   « Dossier SP ERP oui/non » (`erp_sharepoint_folder_id`).
3. Script diag OVH lecture seule pour marché 200 / C2780.

### Base locale Cursor

`marches.id=200`, `programmes.id=18`, `siwi C2780` **ABSENTS** de la DB locale —
preuve prod = script OVH + UI.

## DÉPLOIEMENT-TEST

```bash
git pull origin main
php artisan optimize:clear && php artisan view:clear
php artisan journal:sync
```

Procédure Robin (après déploiement) :
1. `/siwi-import` → opération VILLMINE00 / AROME.
2. Ouvrir marché C2780 (ERP #200) : lire « Dossier SP ERP : oui|non » et « État dépôt ».
3. Cliquer **Déposer documents** (pas les cases) ; noter progression et toast.
4. SharePoint : `TRAVAUX/{POSTE}--{ENT}--MCH-2026-197/` + PDF sous branche.
5. Optionnel OVH : `php tools/diag/diag_siwi_dossier_marche_1359.php` puis
   `grep -E "siwi.marche_cree_sharepoint|SharePoint:.*lotissement|marche_id.:200" storage/logs/laravel.log | tail -40`

## LEÇON

1. Cases cochées ≠ dépôt : prouver le mécanisme **peuplé** (etat_depot_docs +
   sharepoint_item_id), jamais l’UI seule.
2. `creerDossierMarche` qui retourne `null` sans throw était invisible au niveau SIWI.
3. Docs — = stats dépôt vides / aucun item_id, pas un indicateur de dossier marché.
