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

util: fix parseEnv handling of invalid lines #56778

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

AugustinMauroy
Copy link
Member

This PR fixes an issue with util.parseEnv() where invalid lines in the input were being incorrectly concatenated into key names instead of being skipped. The fix ensures that lines without an equals sign are properly skipped during parsing

Fixes: #56775

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Jan 26, 2025
@AugustinMauroy AugustinMauroy force-pushed the util-fix-parseEnv-handling-of-invalid-lines branch from de3dd86 to 8dd566f Compare January 26, 2025 23:53
Copy link
Member

@anonrig anonrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Even though this test pass, I strongly recommend adding as much as comment possible while simplifying your code. Our parser is already complex (due to not using a regex) and it would help a lot if we know why such decision is taken in the parser.

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 85.71429% with 5 lines in your changes missing coverage. Please review.

Project coverage is 90.23%. Comparing base (db4dcc0) to head (6cb8a70).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/node_dotenv.cc 85.71% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56778      +/-   ##
==========================================
- Coverage   90.24%   90.23%   -0.02%     
==========================================
  Files         630      630              
  Lines      184921   184937      +16     
  Branches    36185    36192       +7     
==========================================
- Hits       166879   166874       -5     
- Misses      11065    11073       +8     
- Partials     6977     6990      +13     
Files with missing lines Coverage Δ
src/node_dotenv.cc 86.38% <85.71%> (+0.67%) ⬆️

... and 26 files with indirect coverage changes

@AugustinMauroy
Copy link
Member Author

Yup yagizz, I had tried to apply yours suggestions. I'm reaching my limit in C++. So I hope that this time if it's good.

@anonrig
Copy link
Member

anonrig commented Jan 27, 2025

Yup yagizz, I had tried to apply yours suggestions. I'm reaching my limit in C++. So I hope that this time if it's good.

I see lots of changes unrelated to your PR. Can you revert everything that is unrelated to your change?

@AugustinMauroy
Copy link
Member Author

Bump @anonrig 👋

@anonrig
Copy link
Member

anonrig commented Feb 6, 2025

Bump @anonrig 👋

@AugustinMauroy the tests are failing

@AugustinMauroy
Copy link
Member Author

@AugustinMauroy the tests are failing

How to run test that fail ?? I din't get what should I do

@targos
Copy link
Member

targos commented Feb 6, 2025

@aduh95 Maybe you could help here? The failure is specific to directories with special chars.

@AugustinMauroy AugustinMauroy force-pushed the util-fix-parseEnv-handling-of-invalid-lines branch from 51d9aad to 2a6ba9d Compare February 6, 2025 09:35
@mertcanaltin
Copy link
Member

mertcanaltin commented Feb 14, 2025

@AugustinMauroy the tests are failing

How to run test that fail ?? I din't get what should I do

This should work make test-only (for c and js)

if it is a specific js test ./node test-name.js

for more:
https://github.com/nodejs/node/blob/main/BUILDING.md#running-tests

@AugustinMauroy
Copy link
Member Author

Thanks mert 🫶🏻

@RafaelGSS RafaelGSS added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 28, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 28, 2025
@nodejs-github-bot
Copy link
Collaborator

@AugustinMauroy AugustinMauroy force-pushed the util-fix-parseEnv-handling-of-invalid-lines branch from 9fd762f to 6cb8a70 Compare March 1, 2025 11:36
@nodejs-github-bot
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

util.parseEnv creates keys from invalid, newline-separated lines
7 participants