mirror of
https://github.com/ansible/ansible.git
synced 2025-11-30 23:16:08 +07:00
Include result origin in broken conditional message instead of result (#85695)
Co-authored-by: Matt Clay <matt@mystile.com>
This commit is contained in:
3
changelogs/fragments/elide_broken_conditional_result.yml
Normal file
3
changelogs/fragments/elide_broken_conditional_result.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
bugfixes:
|
||||
- conditionals - When displaying a broken conditional error or deprecation warning,
|
||||
the origin of the non-boolean result is included (if available), and the raw result is omitted.
|
||||
@@ -6,7 +6,6 @@ from __future__ import annotations
|
||||
import copy
|
||||
import dataclasses
|
||||
import enum
|
||||
import textwrap
|
||||
import typing as t
|
||||
import collections.abc as c
|
||||
import re
|
||||
@@ -560,9 +559,11 @@ class TemplateEngine:
|
||||
|
||||
bool_result = bool(result)
|
||||
|
||||
result_origin = Origin.get_tag(result) or Origin.UNKNOWN
|
||||
|
||||
msg = (
|
||||
f'Conditional result was {textwrap.shorten(str(result), width=40)!r} of type {native_type_name(result)!r}, '
|
||||
f'which evaluates to {bool_result}. Conditionals must have a boolean result.'
|
||||
f'Conditional result ({bool_result}) was derived from value of type {native_type_name(result)!r} at {str(result_origin)!r}. '
|
||||
'Conditionals must have a boolean result.'
|
||||
)
|
||||
|
||||
if _TemplateConfig.allow_broken_conditionals:
|
||||
|
||||
Reference in New Issue
Block a user