Summary
When a scenario mock includes msg: in a success: false response, the framework crashes with TypeError: fail_json() got multiple values for keyword argument 'msg'. This is caused by fail_json receiving msg both as an explicit keyword argument and again via **response_data.
Affected file
ansible_playtest/ansible_mocker/mock_ansible_adapter.py
error_msg = response_data.get("error_message", "Mock service failure")
module.fail_json(msg=error_msg, **response_data)
# ↑ if response_data still contains 'msg:', Python raises TypeError
Reproducer
Scenario YAML:
service_mocks:
my_module:
success: false
msg: "Connection refused" # ← triggers the crash
Running any test with this scenario raises:
TypeError: fail_json() got multiple values for keyword argument 'msg'
Expected behaviour
The framework should either:
- Document that
msg: is a reserved key and raise a clear validation error at scenario-load time, or
- Consume
msg from response_data before calling fail_json (e.g. prefer it as error_msg if present).
Suggested fix
# Pop 'msg' from response_data to avoid the collision
error_msg = response_data.pop("msg", None) or response_data.pop("error_message", "Mock service failure")
module.fail_json(msg=error_msg, **response_data)
Workaround
Use error_message: instead of msg: in all success: false mock responses.
Summary
When a scenario mock includes
msg:in asuccess: falseresponse, the framework crashes withTypeError: fail_json() got multiple values for keyword argument 'msg'. This is caused byfail_jsonreceivingmsgboth as an explicit keyword argument and again via**response_data.Affected file
ansible_playtest/ansible_mocker/mock_ansible_adapter.pyReproducer
Scenario YAML:
Running any test with this scenario raises:
Expected behaviour
The framework should either:
msg:is a reserved key and raise a clear validation error at scenario-load time, ormsgfromresponse_databefore callingfail_json(e.g. prefer it aserror_msgif present).Suggested fix
Workaround
Use
error_message:instead ofmsg:in allsuccess: falsemock responses.