Headcount: user_institutional_id Mandatory Again¶
Problem¶
docs/src/implementation-plans/951-edit-rights-per-dataset-permissions.md
made HeadCountCreate.user_institutional_id optional (str | None = None)
so a manually-added member without a known SCIPER could be filled in later.
Success criteria changed: the field must be mandatory at creation again, in
both backend and frontend.
Change¶
backend/app/modules/headcount/data_entries.py:HeadCountCreate. user_institutional_idback tostr(wasstr | None = None). Itsfield_validatoris restored asmode="after"rather than the pre-#951mode="before"— pydantic type-checks the field first, so anullor non-string value now yields a clean 422 instead of anAttributeErrorfromNone.strip()(matchesvalidate_name's pattern two lines above).HeadCountUpdateis untouched — it's a partial-update DTO where every field is optional by design, independent of creation mandatoriness.frontend/src/constant/module-config/headcount.ts:user_institutional_idfield gainsrequired: true(the genericModuleForm.vuerequired-field check already handlestext-type fields viai.required; no dedicated UI code needed).backend/tests/unit/modules/test_headcount_schemas.py: moveduid-missingback to the invalid-permutation list, addeduid-nonethere (was untested pre-#951; now pins themode="after"behavior above), dropped theuid-omittedvalid case added by #951.
Not changed¶
- CSV ingestion and the Tableau API provider (
headcount_members_api_provider.py) already skip/reject rows with a missing SCIPER upstream ofHeadCountCreate, so they're unaffected. isCompleteHeadcountinModuleTable.vue(row-completeness badge) checks a stalerow.sciper/row.functionkey pair that predates theuser_institutional_id/sius_coderename — pre-existing, out of scope here.HeadCountUpdate.user_institutional_idstaysstr | None = None, and an explicituser_institutional_id: nullin a PATCH still clears it (only""/whitespace are rejected) — a partial edit can blank a field that's mandatory at creation. Flagging this, not fixing it here: it's a pre-existing gap (predates #951), and locking it down is an update-path design call, not part of "mandatory again at creation".frontend/src/types/api/openapi.d.tsis not regenerated: the create/update endpoint (POST/PATCH .../modules/{module_id}/{submodule_id}) takes a rawitem_data: dict, not a typed body model, soHeadCountCreatewas never part of the OpenAPI schema to begin with — confirmed noHeadCountCreateoruser_institutional_id-on-headcount entry exists in the committed.d.ts. (The committedopenapi.snapshot.json/openapi.d.tspair is otherwise already far behind the live schema — regenerating it pulls in a ~1200-line unrelated diff; that staleness predates this change and is out of scope here.)