Skip to content

fix(ini): merge repeated sections instead of dropping earlier keys - #7361

Open
Harsh23Kashyap wants to merge 1 commit into
denoland:mainfrom
Harsh23Kashyap:fix/ini-merge-repeated-sections
Open

Harsh23Kashyap wants to merge 1 commit into
denoland:mainfrom
Harsh23Kashyap:fix/ini-merge-repeated-sections

Conversation

@Harsh23Kashyap

Copy link
Copy Markdown

Fixes #7360.

When the same section header appears twice, parse replaces the first section's object with a fresh one, so every key from the earlier occurrence vanishes without an error:

parse("[s]\na=1\n[s]\nb=2");
// before: { s: { b: 2 } }   (a=1 silently gone)
// after:  { s: { a: 1, b: 2 } }

With this change a repeated section name reuses the existing section object, so the keys merge. That matches what node-ini does, and it composes with the rules parse already pins elsewhere: a key repeated across the two occurrences still resolves last-assignment-wins (same as a repeated key within one section), and a top-level key sharing the section's name is still replaced by the section.

Python's configparser raises DuplicateSectionError for this instead. Merging felt like the better fit here since parse never throws for repeated content anywhere else.

Tests added for the merge, the last-wins key case, and the top-level key collision. deno test -A ini/, deno lint ini/, and deno fmt --check ini/ all pass.

@github-actions github-actions Bot added the ini label Oct 19, 2026
@CLAassistant

CLAassistant commented Oct 19, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.04%. Comparing base (f834d02) to head (60e728a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7361      +/-   ##
==========================================
- Coverage   95.04%   95.04%   -0.01%     
==========================================
  Files         619      618       -1     
  Lines       52012    51765     -247     
  Branches     9450     9405      -45     
==========================================
- Hits        49434    49199     -235     
+ Misses       2031     2022       -9     
+ Partials      547      544       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@std/ini parse silently drops an entire section when the section name repeats

2 participants