Skip to content

Columns listed as optional seem to be reuquired #22

@kentico-matthews

Description

@kentico-matthews

Describe the bug
In ./docs/Usage-Guide.md, many contact columns are marked as optional. However, if you try to import a CSV that lacks these columns, e.g. ContactLastName or ContactAddress1, the contacts are not imported, and CsvHelper logs an error like the following:

CsvHelper.HeaderValidationException: Header with name 'ContactLastName'[0] was not found.
Headers: 'ContactGUID', 'ContactCreated', 'ContactFirstName', 'ContactEmail', 'ContactAddress1', 'ContactMiddleName'
If you are expecting some headers to be missing and want to ignore this validation, set the configuration HeaderValidated to null. You can also change the functionality to do something else, like logging the issue.

If you're using the source code of this repo, you can change the CsvConfiguration object, setting both
HeaderValidated = null, and MissingFieldFound = null,. However, if you are using the package instead, this is not possible.

To Reproduce
Steps to reproduce the behavior:

  1. Download the sample CSV file from this repo
  2. Edit the file to remove the ContactAddress1 column, or a different optional column
  3. Import the CSV

Expected behavior
The optional columns should not cause an exception that prevents the contacts from importing

Next steps
We should investigate the CSV Helper code and how we are setting it up to parse the file. If there is no way to make these columns optional there, we could check configuration for some key that will tell our code to set HeaderValidated and MissingFieldFound to null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions