Skip to content

Conversation

@PRAteek-singHWY
Copy link
Contributor

Summary

This PR adds layered validation to the MyOpenCRE CSV import endpoint while preserving full compatibility with OpenCRE-exported CSV templates.

The intent is to make imports safer and errors clearer without introducing stricter requirements than those enforced by the exporter itself.


What’s included

This change introduces validation in three scoped stages:

1. File-level validation

  • Rejects missing files
  • Rejects non-CSV uploads
  • Rejects empty files
  • Ensures UTF-8 encoded content

2. Schema / header validation

  • Ensures a header row exists
  • Requires at least one CRE* column
  • Requires standard metadata columns:
    • standard|name
    • standard|id

3. Row-level validation (export-compatible)

  • Skips empty and padding rows commonly present in exported templates
  • Allows rows without CRE references (as produced by exports)
  • Validates CRE format only when CRE values are present
  • Validates standard metadata only for rows that reference CREs
  • Returns structured, row-specific validation errors before import execution

Why this approach

The OpenCRE exporter currently produces CSV files that may contain:

  • empty rows
  • padding rows
  • rows without CRE references

The importer now explicitly supports these cases and enforces validation only where semantic meaning exists. This ensures:

  • safer imports
  • clearer error reporting
  • no regressions for exported files

Out of scope

Frontend error rendering improvements are intentionally left out and will be handled in a follow-up PR to keep this change focused and easy to review.

@PRAteek-singHWY PRAteek-singHWY deleted the tier1-csv-validation-work branch December 28, 2025 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant