magento2-functional-testing-framework icon indicating copy to clipboard operation
magento2-functional-testing-framework copied to clipboard

Cannot set JSON config value using magentoCLI

Open navarr opened this issue 4 years ago • 3 comments

Preconditions

  1. Magento 2.3.4 (incl. Vertex) w/ MFTF 2.5.3 (cursory glance suggests issue occurs with develop branch)

Steps to reproduce

  1. Modify test VertexAsRegisteredCustomerCheckTaxWhenFlexibleFieldIsSentForEcoProducts to not after step setupFlexFieldConfig
  2. Modify before step setupFlexFieldConfig in same test to be:
<magentoCLI stepKey="setupFlexFieldConfig" command="config:set" arguments='tax/vertex_flexfields/code &apos;[{"field_id":"1","field_source":"product.custom.$$createProductAttribute.attribute_code$$"}]&apos;' />
  1. Check core_config_data table for path 'tax/vertex_flexfields/code'

Expected result

  1. Value is [{"field_id":"1","field_source":"product.custom.[CODE]"}]

Actual result

  1. Value is \[\{\"field_id\":\"1\",\"field_source\":\"product.custom.[CODE]\"\}\]

This is caused by PHP's escapeshellcmd method call: https://github.com/magento/magento2-functional-testing-framework/blob/develop/etc/config/command.php#L26

https://github.com/magento/magento2-functional-testing-framework/blob/d82e6cf1e798a3266ae23582ae53fc6b77fa452d/etc/config/command.php#L25-L27

If the &apos; is not included, the result instead has the brackets not escaped (properly) but removes the quotation marks entirely. I have failed to find any combination of escaping that comes out of escapeshellcmd in a way that sets this configuration value correctly.

By itself, it is handled properly by escapeshellarg but I am not aware of any reliable way to automatically determine individual arguments in $arguments

navarr avatar Mar 23 '20 20:03 navarr

Idea 1: Add noEscape tag to <magentoCLI, that disables escape for arguments=""

CC @okolesnyk

lbajsarowicz avatar Mar 23 '20 20:03 lbajsarowicz

@navarr Thank you for reporting the issue! Internal ticket https://jira.corp.magento.com/browse/MQE-2239 is created.

jilu1 avatar Jul 28 '20 15:07 jilu1

Hey @navarr Could you please confirm if that's still an issue? We fixed a similar issue quite a while ago and before closing this one I just want to make sure it works. Thanks

okolesnyk avatar Mar 22 '22 20:03 okolesnyk