Patch notes — docs folder self-heal on save (2026-06-15)
Each customer company gets a documentation folder (docs/<Company>/ in EthicaDoc) that the
portal renders as its access-gated section. Creation used to be one-shot — it ran only
from the company add-form — so a company could end up with no folder and nothing would
backfill it.
What was missing
- Companies created before the docs integration was configured, or whose create-time Gitea call failed (token/URL unset or unreachable at the time).
- Companies created by lead → convert (that path never called the folder helper).
- The plain company Overview → Save didn’t create a folder either (it was update-only).
There is no background sweep that checks for missing folders — so those companies stayed folder-less until manually fixed.
Fix
ensure_company_docs_folder() now also runs on the company Overview → Save and on
lead → convert, alongside the add-form. It is:
- Idempotent — it
PUTsdocs/<Company>/README.mdand treats Gitea’s “already exists” (HTTP 409/422) as success, so it never duplicates or overwrites. - Best-effort — a missing Gitea config or a failed call never blocks the save (it’s
audited as
company.docs_folder).
So re-saving a company guarantees its folder exists — a one-click backfill for anything that predated the integration. A save is the reconcile point; no polling is involved.
Known limit
Rename is not yet a move: renaming a company creates a folder for the new name but leaves the old-name folder orphaned, and the portal section/grant is keyed on the name too. Handling a rename (move the folder + re-point grants) is a separate change.