Skip to content

Fix ini.set_option deleting indented options#69689

Open
ggiesen wants to merge 2 commits into
saltstack:3006.xfrom
ggiesen:fix-36354-ini-indented-options
Open

Fix ini.set_option deleting indented options#69689
ggiesen wants to merge 2 commits into
saltstack:3006.xfrom
ggiesen:fix-36354-ini-indented-options

Conversation

@ggiesen

@ggiesen ggiesen commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Defect: in salt/modules/ini_manage.py _Section.refresh, an indented config line (e.g. git-style ' url = ...') was meant to be appended to the previous option's value, but when a section began with indented options and had no prior option to append to, the code hit 'continue' and silently discarded the line before gen_ini rewrote the file, so set_option on another section deleted those options. Fix moves the 'continue' inside the 'if options:' branch so orphaned indented lines fall through to the normal key/value regex match and are preserved (indentation is dropped on round-trip, which matches the issue's accepted outcome). Added a regression test with the git-config fixture; verified it passes with the fix and, via a direct functional check, that both indented options come back as None on the unpatched code.

What issues does this PR fix or reference?

Fixes #36354

Previous Behavior

See #36354.

New Behavior

Fix ini.set_option deleting indented options. Validated by a unit test proven to fail on unpatched 3006.x and pass with the fix (confirmed by adversarial review).

Merge requirements satisfied?

  • Tests written/updated
  • Changelog

Commits signed with GPG?

No

In _Section.refresh, an indented line was appended to the previous
option's value, but when a section began with indented options (no prior
option to append to) the line hit 'continue' and was silently discarded.
Move the 'continue' inside the append branch so orphaned indented lines
fall through to the normal key/value match and are preserved.

Fixes saltstack#36354
The direct test calls _Section.refresh() itself the way _Ini.refresh does in
production (section body passed positionally as inicontents with separator="=",
refresh() invoked with no arguments) on a git-style section whose options are
all indented, which the old code silently dropped. The inverse test guards
against overcorrection by verifying an indented line following a normal option
is still folded into that option's value as a continuation line rather than
parsed as a separate entry.
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.

1 participant