Skip to content

debconf: Convert value when vtype is seen - #85692

Open
Akasurde wants to merge 2 commits into
ansible:develfrom
Akasurde:i85683
Open

Akasurde wants to merge 2 commits into
ansible:develfrom
Akasurde:i85683

Conversation

@Akasurde

Copy link
Copy Markdown
Member
SUMMARY
  • Handled case when vtype is seen
  • Fixed idempotency for debconf settings where vtype is seen
  • Added tests for value conversion

Fixes: #85683

Signed-off-by: Abhijeet Kasurde Akasurde@redhat.com

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

changelogs/fragments/debconf_seen_flag.yml
lib/ansible/modules/debconf.py
test/integration/targets/debconf/tasks/main.yml

@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. module This issue/PR relates to a module. has_issue needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Aug 18, 2025
@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Aug 18, 2025
@s-hertel s-hertel removed the needs_triage Needs a first human triage before being processed. label Aug 19, 2025
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Sep 2, 2025
@Akasurde
Akasurde requested a review from bcoca September 8, 2025 15:11

@s-hertel s-hertel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change makes sense to me. Since the value is type "raw", I think we should add more validation. If the coerced value isn't "true" or "false", the module should give an error. If the vtype is not multiselect/boolean/seen, the module should check value is a string.

@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jan 5, 2026
@Akasurde
Akasurde requested a review from s-hertel January 5, 2026 18:47

@s-hertel s-hertel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The same line in set_selection causes unclear failure messages for other vtypes too. Since set_selection is the only "validation" for other vtypes, it also means check mode won't detect the issue (and instead will always return changed as True).

from ansible.module_utils.common.validation import _check_type_str_no_conversion

if vtype not in ('boolean', 'seen', 'multiselect'):
    value = _check_type_str_no_conversion(value) 

Comment thread lib/ansible/modules/debconf.py Resolved
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jan 19, 2026
* Handled case when vtype is seen
* Fixed idempotency for debconf settings where vtype is seen
* Added tests for value conversion

Fixes: ansible#85683

Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
@Akasurde
Akasurde requested a review from s-hertel March 26, 2026 15:32
@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Mar 26, 2026

@s-hertel s-hertel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This generally looks good to me. I noticed a couple little bugs with diff and check mode.

Diff mode shows the requested seen value replacing the value for the question. For example, this question was seen, setting seen to false shows:

--- before
+++ after
@@ -1,3 +1,3 @@
 {
-    "mypackage/some-feature": "value"
+    "mypackage/some-feature": "false"
 }

Not sure if the diff format should be kept the same for vtype seen, but this would at least compare the right values:

         curr = {question: value}
         if question in prev:
-            prev = {question: prev[question]}
+            prev = {question: existing}

The second bug is that invalid values for multiselect aren't detected in check mode when the question is not in the variable prev.

Comment thread lib/ansible/modules/debconf.py Resolved
Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This issue/PR relates to a bug. has_issue module This issue/PR relates to a module. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

debconf fails with TypeError when value is a boolean (e.g., with vtype: seen)

3 participants