add yaml dumper representator for str type to keep quotes always.#436
Conversation
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
fujitatomoya
left a comment
There was a problem hiding this comment.
this make sure that yaml dumper uses quotes to str object during dumping, so that rcl_yaml_param_parser (libyaml) can recognize that as str always. e.g) "123E5".
danielcranston
left a comment
There was a problem hiding this comment.
@fujitatomoya Thanks, this indeed resolves the issue! FWIW, I also went with the yaml.add_representer approach in the test I mentioned in the linked issue:
I did a quick (rclcpp) test of solution 1 above, and indeed with explicit quotes in the temporary YAML the issue disappears.
So I approve of the approach 🙂
I think we can reduce the diff though, see the comment and let me know what you think.
Also, if a maintainer reads this and wants an easy way to reproduce, you can clone and build this branch, then run
ros2 launch parameter_test test.launch.py param:=123E5
Before applying this PR:
[parameter_test-1] terminate called after throwing an instance of 'rclcpp::exceptions::InvalidParameterTypeException'
[parameter_test-1] what(): parameter 'param' has invalid type: Wrong parameter type, parameter {param} is of type {string}, setting it to {double} is not allowed.
[ERROR] [parameter_test-1]: process has died [pid 10097, exit code -6, cmd 'path/to/ws/install/parameter_test/lib/parameter_test/parameter_test --ros-args -r __node:=param_test --params-file /tmp/launch_params_xzypvhlu'].
Contents of "/tmp/launch_params_xzypvhlu" (The lack of quotes is the issue)
/**:
ros__parameters:
param: 123E5
After applying this PR:
[parameter_test-1] [INFO] [1738674287.523757293] [param_test]: param is 123E5
Contents of the associated YAML params file in /tmp (all strings have explicit quotes)
"/**":
"ros__parameters":
"param": "123E5"
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
|
Pulls: #436 |
|
The |
They all seem to be this, maybe the governance filename isn't making it through the YAML (str vs bytes or something like that?) |
|
it does not ring a bell for me, need to look into those. @danielcranston do you have any thoughts? |
|
I'm new to the Some org-wide github search yielded these: Maybe there's some flakiness going on? The "Linux build (retry)" one seems to have passed. |
Yeah, there is a long-time flake there, where every once in a long while, the security tests fail. A "governance" file has to do with how our security works. Regardless, since the rebuild worked, you can safely ignore it. |
Thanks for the info! @fujitatomoya I think it would be good to add a test for this. Is there an easy way to test it? |
@christophebedard that is a good question, let's see what i can do here... |
|
@christophebedard i had a quick scan, it would be hard to add the actual test case for this. for doing this, we do need the actual node implementation of specific type of parameter, and using
|
|
@christophebedard at least, @danielcranston 's reproducible test is passing and i also made sure locally, and all tests are pass. i would want to go merge this one and create another issue to add more tests for ros2launch. what do you think? if there are good approach, i am listening 👂 |
…s2#436) * add yaml dumper representator for str type to keep quotes always. Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com> * representator should be applied to conversion from py dictionary. Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com> --------- Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com> Signed-off-by: Markus Kramer <kramer@sim.tu-darmstadt.de>
closes #384