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

Add allowDuplicateHeaders option to configuration and update tests #1080

Closed
wants to merge 1 commit into from

Conversation

tnrich
Copy link

@tnrich tnrich commented Jan 9, 2025

The automatic duplicate header parsing introduced in a recent version, while helpful for new development, has broken existing legacy code in our codebase.

This PR adds a flag allowDuplicateHeaders which can be set to true to revert to the earlier functionality (as seen in v5.2.0 - that's the version we were on)

Let me know if this PR needs anything else and thanks for the consideration! Love papaparse :)

@pokoli
Copy link
Collaborator

pokoli commented Jan 10, 2025

A list of renamedHeaders is returned as part of the result, so you can read the values and keep the previous behaviour.

You just need to adapt your legacy code to read this new data.

There is nothing to do from the PapaParse side.

@pokoli pokoli closed this Jan 10, 2025
@tnrich
Copy link
Author

tnrich commented Jan 10, 2025

@pokoli that isn't entirely true.. the other benefit to my legacy code from this option would be to prevent transformHeader from being run multiple times for the same header, see - #1029

Unfortunately the code added to rename the headers causes the tranformHeader function to be called a 2nd time which breaks code in our codebase that is depending on that function being run only once per header (which I don't think was an unreasonable assumption and allowed us to do custom logic in our CSV parser)

Why not add this simple option to optionally undo a BREAKING change that was pushed in a MINOR version? This doesn't seem like an unreasonable request and I believe would give an immediate fix to a whole host of tickets related to the changes made after v5.3.2 -

#1054 #1054 #998 #1006

I'm not suggesting that those shouldn't be fixed but it isn't a good practice to push a breaking change in a minor version without any recourse for end users.

@tnrich
Copy link
Author

tnrich commented Jan 10, 2025

Hope the above comment doesn't come off as harsh. Appreciate your stewardship of this important repo @pokoli! Overall I agree that the header de-dupe is a step in the right direction, unfortunately a lot of legacy code will be broken by the two changes (automatic header dedupe and additional calling of transformHeader).

@Targzp
Copy link

Targzp commented Jan 16, 2025

I am disappointed that the author did not respond to your follow-up questions. I also encountered the same problem.

@danieljbrooks-GitHub
Copy link

And I as well

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.

4 participants