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
Version 5.2.0+ -- TypeError: Cannot read property 'reduce' of undefined #188
Comments
Submitted PR #189 which will fix this issue. |
Thanks @jamonholmgren for the issue and PR. Can you please explain more the specific usage that raises this error? That will help clarify the situation, and will help make a useful changelog entry for the fix. |
Hey @davidtheclark, I'm not entirely sure, to be honest. I only upgraded from cosmiconfig 5.1.0 to 5.2.0 without any other changes to my code and it blew up. I could try to track down the specific code in Gluegun that is passing in an Beyond that, the API difference between the hand-rolled version of Thanks for taking a look! |
So the first failing test is relying on cosmiconfig to fail quietly during a unit test where the unit doesn't declare all the data it would otherwise have in a happy path scenario. This is unfortunately caused because we don't enforce the e.g.
Gluegun is then relying on this behavior and expects the following to return null
So although I do think this fix should be introduced as a patch in order to make the behavior consistent with previous versions - I could also see wanting to add a check to make sure |
Thanks for digging in, @olsonpm. So this is one of those pesky cases where usage contrary to the publicly documented API (
I would favor fixing the bug (unpredictable behavior when you don't pass a required parameter) rather than codifying the bug as a feature. Since this fix would be perfectly compatible with the publicly documented API, a patch release is what semver expects ("Bug fixes not affecting the API increment the patch version"). (Yes, this might break somebody's build if they're relying on the undocumented buggy behavior, but that's always a danger when fixing a bug.) If we are going to add type assertions against the Any objections to that proposal: fixing this with parameter type assertions, and releasing that as a patch? |
No objections here. I just do think this is a value judgement because if we were talking about a larger product whose api has been stable for a long time, then I believe the bug fix similar to this one ought to be considered a breaking change because of the potential negative affect of changing it. In our case I think it's fine though. If enough people run into issues because they depended on similar behavior, we can revert and add the check in a branch for v6. I can submit a PR to Gluegun to add an if statement to prevent the tests from failing. |
No objections -- you're correct, and I really appreciate the offer of a PR to fix the failing test! Top notch open source support. 💜 |
Closing as stale. I hope the issue was fixed by the Gluegun PR mentioned above. |
@davidtheclark Thanks, I did manage to track down the |
When upgrading gluegun from Cosmiconfig 5.1.0 to 5.2.0, I'm getting an error in my tests:
There are no other changes -- tests pass on 5.1.0 and fail with this error on 5.2.0.
Here's the diff 5.1.0 to 5.2.0: https://github.com/davidtheclark/cosmiconfig/compare/71da3267ff24b3e80bd0e5fc955b4c45942c3548..f1750cde0b9c53bc577efa60d012a85a4dc4b823
If you'd like to experience it for yourself, do this:
This also happens on the latest cosmiconfig, 5.2.1.
The text was updated successfully, but these errors were encountered: