15:03:41 #startmeeting Ansible Core Public IRC Meeting 15:03:41 Meeting started Thu Jul 22 15:03:41 2021 UTC. 15:03:41 This meeting is logged and archived in a public location. 15:03:41 The chair is sdoran. Information about MeetBot at http://wiki.debian.org/MeetBot. 15:03:41 Useful Commands: #action #agreed #halp #info #idea #link #topic. 15:03:41 The meeting name has been set to 'ansible_core_public_irc_meeting' 15:04:34 Just one item on the agenda today. 15:04:44 #topic https://github.com/ansible/ansible/pull/75247 15:05:15 I've definitely hit that bug before 15:06:27 or rather, I considered that not a bug, but the new behavior a bug... IIRC there's some other similar filter to this that returns empty string vs false with no match 15:06:30 Not many in attendance today. 15:08:22 I would suggest to not merge this in a bugfix release, but keep it for 2.12, and label it as a `breaking_change`, since this can change behavior for some people 15:08:23 cyberpear: what is "the new behavior"? 15:09:35 mkrizek: in the current behavior, you can distinguish between "no match found" and "matched empty string" 15:10:14 (within the same jinja template, obviously) 15:10:55 * cyberpear looks for issue to see what problems it's causing 15:11:17 'new behaviour' is 'consistent' 15:11:21 no matter the context 15:11:27 yeah, I know for new things we don't want variant return types 15:11:29 vs current which changes '' or None depending on context 15:11:47 well, variants are ok if documented, many filters /lookups do this 15:11:53 the problem is tha tit is contrary to doc 15:12:24 #chair bcoca 15:12:24 Current chairs: bcoca sdoran 15:13:18 And the problem is if we change it for this filter we will need to change it for others. 15:14:00 Returning `None` is more Pythonic, but may not make as much sense to a non-programmer. 15:14:19 I find current behavior more useful for the same reasons as cyberpear, but I think in this case consistency is more important since not all ansible users are programmers. 15:15:18 the bug doesn't describe the issue, only describes the behavior as not matching docs 15:15:31 i.e., what broke as-is? 15:16:23 how many other instances do we return `None` but don't document it as such? 15:16:26 using it with another filter that expected a string 15:17:15 Or a comparison to an empty string. 15:17:16 we would have to look into it, the 'None to '' ' is a sideeffect on how we process jinja2, so if its 'final result' you get '' (as documented) but as 'intermediate result' the None persists 15:17:27 Using `truthy` or `falsy` tests would be better. 15:17:27 cyberpear: why would you "match empty string"? isn't an empty string contained in all strings? 15:18:36 result |type_debug == 'string' 15:18:44 many ways it breaks 15:18:45 mkrizek: you'd think so, but when using regex lookaround to parse out a value that could be an empty value but the lookaround part matched 15:20:38 I'd suggest that whatever the decision here be documented as a TODO for any other mis-matched filters 15:21:12 so something I brought up during triage, is that this kind of breaks the ability to determine if the pattern didn't match, vs the pattern matching an empty string 15:21:16 We can either 1) Update the docs or 2) Update this filter to return an empty string (and probably several others). 15:21:44 Good point. `None` potentially provides more information than `''`. 15:22:43 _finalize is just evil 15:22:55 sivel++ 15:25:49 I do realize how complicated it makes documented the behavior of a filter like this, but I also still believe the current behavior of `regex_search` shouldn't be modified 15:26:38 im 50/50 15:26:49 and its really not the filter's fault but our postprocessing 15:27:48 that postprocessing tripped me up more than once 15:28:01 now I am 50/50 too and I think the best solution here is to ignore it ;-) 15:28:05 but it's hard to get rid of 15:28:40 I think that in this case, improving the docs is better than changing the behavior 15:29:04 I'm in favor of updating the docs and keeping the behavior. 15:29:50 an advantage of that is also that it's not a breaking change :) 15:29:50 Note that we're also pushing toward a future of jinja2 native being a forced requirement 15:30:03 is this something helped by the native_types `ANSIBLE_JINJA2_NATIVE`? 15:30:28 cyberpear: yes, jinja2 native bypasses the None -> "" translation in Templar._finalize 15:31:06 and we're planning to drop `safe_eval`, and transition to required jinja2 native 15:31:27 If the native types are what is seen as the way forward, then documenting is definitelly the better option here. 15:32:18 Although jinja's native type support has its own set of "interesting" behavior ... 15:32:24 change docs to 'return None' and then add docs about 'non native and none' 15:33:09 is safe_eval what tries to avoid templating stuff that came from a managed node? 15:33:58 cyberpear: `safe_eval` is what takes the pythons tring repr from jinja2 (non-native) and converts it into Python 15:34:05 python string* 15:34:06 safe_eval is what makes it possible to do things like `loop: "{{ something that returns list }}"`. 15:34:14 cyberpear: https://gist.github.com/mkrizek/dbcf415b485fc3f2d4b3676ce0013397 15:34:17 thx 15:34:40 j2native does the same ... but better 15:35:24 Just for reference: https://jinja.palletsprojects.com/en/3.0.x/nativetypes/ 15:35:34 okay, so this is the sometimes-annoying "if it looks like a json string, parse it out to a datastructure" funcitonality 15:35:46 cyberpear: Yep ;) 15:36:07 cyberpear: But used in even more places. 15:41:07 Sounds like we have reached a consensus to keep the existing behavior but update documentation. 15:41:32 Is that correct? 15:41:51 +1 15:41:54 +1 15:41:59 +1 15:42:23 #topic Open floor 15:44:23 I'll end the meeting shortly if there is nothing further to discuss. 15:50:15 Thank you everyone for participating today. 15:50:17 #endmeeting