Skip to content

Fix bare-string when/assert conditionals rejected by ansible-core 2.17.4 - #385

Merged
ddemlow merged 1 commit into
mainfrom
fix/bare-string-when-conditionals
Oct 29, 2026
Merged

ddemlow merged 1 commit into
mainfrom
fix/bare-string-when-conditionals

Conversation

@ddemlow

@ddemlow ddemlow commented Oct 29, 2026

Copy link
Copy Markdown
Member

Summary

sc_replication_dest_host and features.version_update.next_version are non-empty strings
when configured, "" when not. A bare string used directly in when: or assert.that used
to be truthy-tested implicitly by Ansible, but ansible-core 2.17.4 rejects it with
"Conditionals must have a boolean result" the first time the string is genuinely non-empty.

Found 2026-10-29 on the first real dispatch run against the new Indy-lab fixture (#383):
https://10.6.112.64 is the first host in a long time to set a real, non-empty
sc_replication_dest_host and next_version that actually got exercised by live CI — every
other host's config block in this file uses "" for both, which sidesteps the bug entirely.
Confirmed via two failed jobs on that run:

[ERROR]: Task failed: Conditional result (True) was derived from value of type 'str' at
'.../integration_config.yml:334:31'. Conditionals must have a boolean result.

Not a regression from #383 — this has been a latent bug in these 4 files for a while;
my fixture's honest (non-placeholder) values are just the first thing to trip it.

Fix

All 6 occurrences across 4 files, made explicit rather than relying on implicit bare-string
truthiness:

  • tests/integration/targets/vm_replication_info/tasks/main.yml (×3)
  • tests/integration/targets/remote_cluster_info/tasks/main.yml (×2, one negated)
  • tests/integration/targets/vm_clone__replicated/tasks/main.yml (×1, in an assert.that list)
  • tests/integration/targets/version_update_info/tasks/main.yml (×2, one negated)

sc_config[sc_host].sc_replication_dest_host → sc_config[sc_host].sc_replication_dest_host | length > 0
(and | length == 0 for the negated cases). Chose | length over | bool deliberately —
Ansible's bool filter only recognizes a fixed set of yes/no/true/false-style tokens, and an
arbitrary URL string isn't guaranteed to map the way we want; | length > 0 preserves the
exact original intent ("non-empty string means configured") with no ambiguity.

Confirmed via a standalone jinja2 render that the filter produces the correct boolean for
both "" and real values (https://10.6.112.67, 9.7.9.227018).

Test plan

  • YAML syntax valid on all 4 edited files (done locally)
  • jinja2 | length > 0 / | length == 0 verified against both empty and non-empty
    strings (done locally)
  • Re-run integ-test.yml's vm_replication_info, vm_clone__replicated, and
    version_update_info targets after merge — these are what actually exercise the fix

sc_replication_dest_host and features.version_update.next_version are
non-empty strings when configured, "" when not. A bare string used directly
in when: or assert.that used to be truthy-tested implicitly, but
ansible-core 2.17.4 rejects it with "Conditionals must have a boolean
result" the first time the string is genuinely non-empty.

Found 2026-10-29 on the first real dispatch run against the new Indy-lab
fixture (#383): hypercore-ci-fleet's .64 is the first host in a long time
to set a real, non-empty sc_replication_dest_host and next_version that
actually got exercised by live CI, which is what surfaced this -- every
other host's blocks use "" for both, sidestepping the bug entirely. Not a
regression from #383.

Fixed all 6 occurrences across 4 files by making each boolean test
explicit (| length > 0 / | length == 0), rather than relying on Ansible's
implicit bare-string truthiness. Confirmed with a standalone jinja2 render
that the filter produces the right boolean for both "" and real values.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ddemlow
ddemlow merged commit c3b477d into main Oct 29, 2026
6 checks passed
@ddemlow
ddemlow deleted the fix/bare-string-when-conditionals branch October 29, 2026 11:21
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