Open kyleam opened 8 months ago
safe_based_on
processes the paths with yaml_ext
, removing the ".1" and then goes looking for 1.yaml instead of 1.1:
Fixing this probably involves a wider audit of how we handle this throughout the code base, but some notes:
safe_based_on
says that the paths can be with or without extension, so that's in some sense working as designed.
safe_based_on
is internal, but it directly processes user-supplied values in the add_based_on
, replace_all_based_on
, and remove_based_on
, so it's connected to user-visible behavior.
One fix would be to not permit an extension for the values given to the modify_based_on
functions. The modify_based_on
docs explicitly say that the based on field doesn't have an extension, but it doesn't specify that the input value can't. Presumably the reason safe_based_on
exist is so that it can.
Another option would to be more specific about what extensions are stripped (maybe ".mod", ".ctl", ".yaml"?).
Also note that bbr.bayes gq helpers follow the based-on handling fairly closely and likely have the same issues.
[ issue noticed while reviewing gh-614 ]
Periods are permitted as part of the model ID, and this is documented and tested for
copy_model_from
(and probably elsewhere):https://github.com/metrumresearchgroup/bbr/blob/c6a34e43bedb335bb5bd42edc6c4ac760c1a8cea/R/copy-model-from.R#L57-L58
https://github.com/metrumresearchgroup/bbr/blob/c6a34e43bedb335bb5bd42edc6c4ac760c1a8cea/tests/testthat/test-copy-model-from.R#L155-L173
However, if the parent model has a period,
safe_based_on
fails.