Skip to content
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

fix(netconf_config.py): type conversion issue for confirm_timeout #689

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jclaerhout
Copy link

SUMMARY

This pull request fixes a type conversion issue in the netconf_config module of the ansible.netcommon collection.

When using the confirm parameter, Ansible throws an error due to a type mismatch:

Argument must be bytes or unicode, got 'int'

This occurs because confirm_timeout, which is expected to be an integer, is not properly converted before being passed to the NETCONF commit operation.

The fix ensures confirm_timeout is explicitly converted to a string using to_text() with errors='surrogate_or_strict' before passing it to the commit operation.

Fixes #551


ISSUE TYPE
  • Bugfix Pull Request

COMPONENT NAME

ansible.netcommon.netconf_config


ADDITIONAL INFORMATION

The issue occurs when attempting to use confirm in ansible.netcommon.netconf_config, leading to a failure due to incorrect type handling.

Code Change (Line 669 of netconf_config.py):

- confirmed=confirmed_commit, timeout=confirm_timeout
+ confirmed=confirmed_commit, timeout=to_text(confirm_timeout, errors='surrogate_or_strict')

This fix ensures proper type handling and allows users to correctly perform confirmed commits with rollback timers.

References:

Let me know if any further modifications are required! 🚀

Voici un message de commit clair et concis pour ton pull request :  

Ensure confirm_timeout is correctly converted to a string using `to_text()` to prevent type mismatches.  
This resolves errors like `Argument must be bytes or unicode, got 'int'` when using commit confirmation.  

Change applied in line 669:  
- `confirmed=confirmed_commit, timeout=confirm_timeout`  
+ `confirmed=confirmed_commit, timeout=to_text(confirm_timeout, errors='surrogate_or_strict')`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

netconf_config false argument when using confirm_commit
1 participant