Skip to content

Fix parsing of values on new lines by enabling empty lines in multiline values by default#22

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-14
Open

Fix parsing of values on new lines by enabling empty lines in multiline values by default#22
Copilot wants to merge 2 commits intomainfrom
copilot/fix-14

Conversation

Copy link
Contributor

Copilot AI commented Aug 14, 2025

This PR fixes an issue where the configparser failed to parse values that are placed on a new line after the key, particularly when there are empty lines between the key and value.

Problem

The library was not correctly handling cases like:

[section]
option3 =
    value3

Where parser.Get("section", "option3") would return an empty string instead of "value3" when there were empty lines between the key and the multiline value.

Root Cause

The parsing logic would terminate multiline value parsing when encountering empty lines, unless the AllowEmptyLines option was explicitly enabled. This behavior was counter-intuitive for users who expected standard configuration file multiline value behavior.

Solution

  • Enable the emptyLines option by default in defaultOptions()
  • Update the existing test case that expected the old behavior to reflect the new, more intuitive behavior
  • Add a comprehensive test case to validate newline value parsing scenarios

Impact

This change makes the library more user-friendly by allowing empty lines in multiline values by default, which aligns with common expectations for configuration file parsing. While this is technically a breaking change in behavior, it makes the library work as users intuitively expect.

All existing tests continue to pass, and the core functionality (interpolation, basic parsing, etc.) remains unchanged.

Fixes #14.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Contributor Author

Copilot AI commented Aug 14, 2025

@bigkevmcd 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Co-authored-by: bigkevmcd <867746+bigkevmcd@users.noreply.github.com>
Copilot AI changed the title [WIP] [BUG] Failed to parse the value when it is in a new line Fix parsing of values on new lines by enabling empty lines in multiline values by default Aug 14, 2025
Copilot AI requested a review from bigkevmcd August 14, 2025 09:49
Copy link
Contributor

@emar-kar emar-kar left a comment

Choose a reason for hiding this comment

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

Hello again. Great to see new updates. This catch is interesting, as I see python's version also enables it by default. Maybe it's also a valid moment to get back to the python version and confirm that other flags are working the same way?

"testing": "multiline\nvalue",
"myoption": "another\nmultiline\nvalue",
"broken_option": "this value will miss",
"broken_option": "this value will miss\n\nits multiline",
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably better to change to will not miss?

Copy link
Owner

Choose a reason for hiding this comment

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

@copilot can you address this feedback?

delimiters: ":=",
commentPrefixes: Prefixes{"#", ";"},
multilinePrefixes: Prefixes{"\t", " "},
emptyLines: true, // Allow empty lines in multiline values by default
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this change should also lead to deprecation of the AllowEmptyLines, since this option will be ON by default and introduction of NoEmptyLines or something similar to bring back old behavior?

Copy link
Owner

Choose a reason for hiding this comment

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

@emar-kar Thanks for the reminder about this - I gave this task to Copilot to figure it out and then forgot about it😄

@bigkevmcd bigkevmcd marked this pull request as ready for review October 17, 2025 06:42
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.

[BUG] Failed to parse the value when it is in a new line

3 participants