Skip to content

Conversation

felixfontein
Copy link
Collaborator

@felixfontein felixfontein added the backport-2.19 Automatically create a backport for the stable-2.19 branch label Aug 11, 2025
@felixfontein
Copy link
Collaborator Author

@samccann
Copy link
Contributor

@felixfontein @mattclay - looks like the referenced issue suggests some of this is updated in the next core 2.19 version. Is the content in this PR update still valid?

@felixfontein felixfontein marked this pull request as draft August 15, 2025 17:54
@felixfontein
Copy link
Collaborator Author

I was planning to check whether the PR mentioned there (ansible/ansible#85652) changed something, but only got to do that now. It actually does (the first string_with_none now is a stringified list without the Nones). Since according to ansible/ansible#85605 (comment) the new behavior isn't fixed it's better to wait until that's finalized.

CC @nitzmahone please add a comment here if/when you decide to change something :)

@mattclay
Copy link
Member

The fixes in ansible/ansible#85652 and ansible/ansible#85676 resolve the issue with concatenation of None resulting in a literal None in the template output. These fixes are being backported (ansible/ansible#85663) and will be included in 2.19.1.

@felixfontein
Copy link
Collaborator Author

I'll rewrite this accordingly somewhen this weekend.

@felixfontein
Copy link
Collaborator Author

@samccann @mattclay @nitzmahone I've split this up into two sections, since now the behavior is different enough that mixing it into one seems wrong to me. Can you please check the result? Thanks!

@felixfontein felixfontein marked this pull request as ready for review August 19, 2025 20:52
"""""""""""""""""""""""""""""""""""""""

If a template evaluated to ``None``, it was implicitly converted to an empty string in previous versions of ansible-core.
This can now result in the template evaluating to the *value* ``None``.
Copy link
Member

Choose a reason for hiding this comment

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

It's worth pointing out that this no longer matters for the common case of passing the template result to a module argument that accepts a string, since None is now automatically converted to an empty string in that case.

See: ansible/ansible#85652

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, I didn't notice that change. That doesn't work for type=list though, where an empty string as a result of a template in 2.18 and before resulted in [""], and now results in an error. But since [""] was seldom the expected value I guess this doesn't matter much...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a note: dbe43f4
Does this look good?

Copy link
Member

Choose a reason for hiding this comment

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

This looks better.

Your point about lists has me wondering if they should default to [] when given None for module arguments, since that's the closest thing to "no list" -- just like we now do for strings defaulting to "" when None is given.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Defaulting to [] would be changing behavior (since depending on where None comes from, it used to be [""] before). That sounds like a can of worm that can cause more bad than good. At least for strings, None either came from a template (and used to be "") or was invalid before.

@felixfontein felixfontein merged commit 87d2e26 into ansible:devel Aug 28, 2025
12 checks passed
Copy link

patchback bot commented Aug 28, 2025

Backport to stable-2.19: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-2.19/87d2e26c15ce5f6e329f51ef5c43ddaefaab54b1/pr-2982

Backported as #3013

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein felixfontein deleted the porting-guide branch August 28, 2025 04:24
@felixfontein
Copy link
Collaborator Author

@samccann @mattclay thanks for reviewing!

patchback bot pushed a commit that referenced this pull request Aug 28, 2025
* Add example of unintentional None to 2.19 porting guide.

* Rewrite into two sections.

* Improve formulations as suggested by samccann.

Co-authored-by: Sandra McCann <[email protected]>

* Remove no longer appropriate section.

* Fix typo and add note.

---------

Co-authored-by: Sandra McCann <[email protected]>
(cherry picked from commit 87d2e26)
felixfontein added a commit that referenced this pull request Aug 28, 2025
* Add example of unintentional None to 2.19 porting guide.

* Rewrite into two sections.

* Improve formulations as suggested by samccann.



* Remove no longer appropriate section.

* Fix typo and add note.

---------


(cherry picked from commit 87d2e26)

Co-authored-by: Felix Fontein <[email protected]>
Co-authored-by: Sandra McCann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-2.19 Automatically create a backport for the stable-2.19 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants