-
Notifications
You must be signed in to change notification settings - Fork 698
Add example of unintentional None to 2.19 porting guide #2982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9ee3e2a
to
be7b4f4
Compare
@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? |
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 CC @nitzmahone please add a comment here if/when you decide to change something :) |
The fixes in ansible/ansible#85652 and ansible/ansible#85676 resolve the issue with concatenation of |
I'll rewrite this accordingly somewhen this weekend. |
@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! |
Co-authored-by: Sandra McCann <[email protected]>
""""""""""""""""""""""""""""""""""""""" | ||
|
||
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``. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Backport to stable-2.19: 💚 backport PR created✅ Backport PR branch: Backported as #3013 🤖 @patchback |
* 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)
* 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]>
Ref: ansible/ansible#85605