Skip to content

CFE-3866: Add workaround for set_variable_values_ini errors when section does not exist (3.27)#3130

Open
nickanderson wants to merge 2 commits intocfengine:3.27.xfrom
nickanderson:CFE-3866/3.27.x
Open

CFE-3866: Add workaround for set_variable_values_ini errors when section does not exist (3.27)#3130
nickanderson wants to merge 2 commits intocfengine:3.27.xfrom
nickanderson:CFE-3866/3.27.x

Conversation

@nickanderson
Copy link
Copy Markdown
Member

This test demonstrates the bug where set_variable_values_ini() emits
'could not select an edit region' errors when called on a file where
the promised section doesn't exist yet.

The test creates an empty file and uses set_variable_values_ini() to
add a section with keys. Without the fix, this produces multiple errors
even though the section is created by the same bundle.

Ticket: CFE-3866

Modified set_variable_values_ini() to check if the section exists before
attempting to use select_region. When the section doesn't exist yet, lines
are inserted after the section header instead of using select_region.

This prevents 'could not select an edit region' errors when the section
is being created by the same bundle in an earlier promise.

The fix:
- Detects if section exists using regline()
- For existing sections: uses select_region (original behavior)
- For new sections: inserts after section header using location => after()
- Adds unique handles to distinguish the two insertion paths

Ticket: CFE-3866
Changelog: Title
(cherry picked from commit 7a010fa)
This test demonstrates the bug where set_variable_values_ini() emits
'could not select an edit region' errors when called on a file where
the promised section doesn't exist yet.

The test creates an empty file and uses set_variable_values_ini() to
add sections with keys. Without the fix in the previous commit, this
produces multiple errors even though the sections are created by the
same bundle.

Ticket: CFE-3866
Changelog: None
(cherry picked from commit 39d13f6)
@nickanderson nickanderson changed the title CFE-3866: Add test for set_variable_values_ini errors when section does not exist (3.27) CFE-3866: Add workaround for set_variable_values_ini errors when section does not exist (3.27) Apr 16, 2026
@nickanderson
Copy link
Copy Markdown
Member Author

@cf-bottom jenkins please

@cf-bottom
Copy link
Copy Markdown

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants