feat(myopencre): improve CSV import validation (export-compatible) #682
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please review this PR after the above PR is merged.
Note for reviewers
The intended change in this PR is limited to
application/web/web_main.py(CSV import validation logic).Any additional file diffs shown by GitHub are inherited from branch history / stacking and are not part of the validation change itself.
Please let me know if you’d prefer this PR to be rebased or split into a narrower diff.
Summary
This PR improves server-side validation for the MyOpenCRE CSV import endpoint, aligning it closely with the CSV format produced by the CRE catalogue export flow.
The intent is not to introduce strict or surprising validation rules, but to ensure that:
What this PR does
File-level validation
Schema / header validation
CRE*columnstandard|nameandstandard|idRow-level validation (export-compatible)
<CRE-ID>|<Name>)No-op import guard
What is intentionally ignored (by design)
This mirrors how production importers typically behave and allows exported files to be round-tripped without manual cleanup.
What is out of scope for this PR
These will be handled in follow-up PRs to keep this change focused and reviewable.
Why this approach
The importer now accepts everything the exporter produces, ignores exporter padding rows, and enforces validation only where semantic meaning exists.
This keeps the import process resilient while still preventing invalid data from entering the system.
Dependency note
This PR is stacked on top of:
feat(myopencre): add CSV upload UI and wire to existing import endpoint (#664)It should be reviewed and merged after that PR.
Feedback welcome
If any validation behavior is too permissive or too strict, or if there are exporter edge cases I may have missed, I’d really appreciate guidance and am happy to adjust.