{"record":{"id":"f0ef139037420241","repo":"ansible/ansible","slug":"0-r-is-not-a-string-and-conversion-is-not-allo","errorCode":null,"errorMessage":"'{0!r}' is not a string and conversion is not allowed","messagePattern":"'(.+?)' is not a string and conversion is not allowed","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/ansible/module_utils/common/validation.py","lineNumber":350,"sourceCode":"\n    :arg value: Value to validate or convert to a string\n    :arg allow_conversion: Whether to convert the string and return it or raise\n        a TypeError\n\n    :returns: Original value if it is a string, the value converted to a string\n        if allow_conversion=True, or raises a TypeError if allow_conversion=False.\n    \"\"\"\n    if isinstance(value, str):\n        return value\n\n    if value is None:\n        return ''  # approximate pre-2.19 templating None->empty str equivalency here for backward compatibility\n\n    if allow_conversion:\n        return to_native(value, errors='surrogate_or_strict')\n\n    msg = \"'{0!r}' is not a string and conversion is not allowed\".format(value)\n    raise TypeError(to_native(msg))\n\n\ndef _check_type_str_no_conversion(value) -> str:\n    return check_type_str(value, allow_conversion=False)\n\n\ndef check_type_list(value):\n    \"\"\"Verify that the value is a list or convert to a list\n\n    A comma separated string will be split into a list. Raises a :class:`TypeError`\n    if unable to convert to a list.\n\n    :arg value: Value to validate or convert to a list\n\n    :returns: Original value if it is already a list, single item list if a\n        float, int, or string without commas, or a multi-item list if a\n        comma-delimited string.\n    \"\"\"","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/ansible/ansible/blob/9cf16a4aca7898481c257f1e17ad28d0b67b1f85/lib/ansible/module_utils/common/validation.py#L332-L368","documentation":"Error \"'{0!r}' is not a string and conversion is not allowed\" thrown in ansible/ansible.","triggerScenarios":"Thrown at lib/ansible/module_utils/common/validation.py:350 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a string value, or enable conversion if the caller supports it.","Quote the value in the playbook to force string type."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9cf16a4aca7898481c257f1e17ad28d0b67b1f85","analyzedAt":"2026-08-15T00:15:47.100Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}