Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 'Column header mismatch' reason gets lost #772

Open
1 of 2 tasks
igor-tatarnikov opened this issue Feb 7, 2022 · 0 comments
Open
1 of 2 tasks

[BUG] 'Column header mismatch' reason gets lost #772

igor-tatarnikov opened this issue Feb 7, 2022 · 0 comments
Assignees
Labels

Comments

@igor-tatarnikov
Copy link

Describe the bug
Hey team,
I might be missing some core idea, but it feels like the 'Column header mismatch...' reason gets lost in some specific use case. Please, take a look.

Parse options:

{
    discardUnmappedColumns: false,
    strictColumnHandling: true,
    headers: function (headers: HeaderArray): HeaderArray {
        // let's say, it makes headers uppercase
    }
}

Event subscription:

.on('data-invalid', (row, rowNumber, reason) => {
    // I would expect the reason to be populated for the row with columns count less / greater than headers count
    // But it's undefined, because the previous function forgot to pass it (check details below)
})

It looks like a small change should fix it:
Instead of

return cb(null, { isValid: false, row: (parsedRow as never) as O });

do

return cb(null, { isValid: false, row: (parsedRow as never) as O, reason: withHeaders.reason });

Parsing or Formatting?

  • Formatting
  • Parsing

To Reproduce
Steps to reproduce the behavior:

  1. Example file contents if applicable
header1,header2
test1,test2,test3
test4
  1. Example code to reproduce the issue.

Parse options:

{
    discardUnmappedColumns: false,
    strictColumnHandling: true,
    headers: function (headers: HeaderArray): HeaderArray {
        // let's say, it makes headers uppercase
    }
}

Event subscription:

.on('data-invalid', (row, rowNumber, reason) => {
    // I would expect the reason to be populated for the row with columns count less / greater than headers count
    // But it's undefined, because the previous function forgot to pass it (check details below)
})

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. MacOS] MacOS
  • OS Version [e.g. Mojave] BigSur
  • Node Version [e.g. 10.16.0] 14

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants