-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ldap_search: callback utf-8 error "surrogates not allowed" on ansible-core 2.14 #5704
Comments
Files identified in the description: If these files are incorrect, please update the |
I get the same error, when I try to output the results |
In general Ansible does not handle binary output well; modules should not return binary output. This is a bit tricky since the ldap_search module doesn't know what it returns, and Base64 encoding everything makes the module harder to work with. One could add an option to the module which allows to specify a list of fields that should be Base64 encoded, then you could make sure that Alternatively (or at the same time), the yaml callback could be fixed to behave better with binary data. @stefanDeveloper are you also using the yaml callback, or are you using another one? |
!component +plugins/callback/yaml.py |
Files identified in the description: If these files are incorrect, please update the |
This used to work in 2.11, don't know what has changed. I do not care much about the binary data but some output would be necessary. I do not know if/how this could work in practice but IMO the easiest solution would be to just check if the data is binary and then just print |
Did anyone check whether this also happens with the default callback? The only examples in this issue where anything more concrete is mentioned are with the community.general.yaml callback. That would help to decide where this error actually comes from (ansible-core or the yaml callback). |
The problem seems to arise with all callbacks (that use |
Hello,
|
I think it's time to create an issue in ansible-core for this, since this is an ansible-core problem, not really a community.general problem. |
I've created ansible/ansible#80258 for this. Please add more examples that are not related to ldap_search there and not here :) |
According to ansible/ansible#80258 (comment) the module must not return binary data as text, so we need to adjust the module's output. I would probably use a similar code as in ansible/ansible#80258 (comment):
Probably we should have some better way to output data, but that can happen later (resp. when someone has a good idea how to actually do it). |
I created a PR to fix ldap_search: #6475 I would be glad if some of you could test this! The PR does two things:
Comments welcome! Since this is a breaking change I want to get this into community.general 7.0.0 (to be released in ~a week), and this won't get backported to 6.x.y or before. |
This PR didn't fix the issue because community.general/plugins/modules/ldap_search.py Lines 161 to 162 in 1beb38c
Thus |
I guess it should have been |
Summary
Searching for computer objects from an Active Directory with the
ldap_search
module fails to print to output search results in-vv
mode ofansible-playbook
and instead aWARNING
is printed about a utf-8 errorsurrogates not allowed
.My guess would be that some of the binary data included in the objects returned by the query is not compatible with the callback plugin's expected UTF-8 encoding.
The same query works on ansible-core 2.11 and prints to output the search results, some attributes in the objects looks like binary data.
Issue Type
Bug Report
Component Name
ldap_search
Ansible Version
Community.general Version
Configuration
OS / Environment
EL9.1, Python 3.9
Steps to Reproduce
Query computer objects from Active Directory and run
ansible-playbook -vv
to make the task print the search results to screen.On ansible-core 2.11 the output includes binary-looking data such as:
Expected Results
The task should print to output the search results in the same way it does on ansible-core 2.11.
Actual Results
[WARNING]: Failure using method (v2_runner_on_ok) in callback plugin (<ansible_collections.community.general.plugins.callback.yaml.CallbackModule object at 0x7f4071cb7b20>): 'utf-8' codec can't encode characters in position 6-9: surrogates not allowed
Instead of printing search results, only the above warning is printed. Otherwise the task seems to work correctly, results are registered.
Code of Conduct
The text was updated successfully, but these errors were encountered: