gramex
gramex copied to clipboard
GRAMEX-188 ⁃ In .yaml file losing the variable's original value at the place of reusing the configuration
In yaml file, variable's original value is getting loose while reusing the configuration.
Steps to reproduce.
variables:
my_pwd: 'Kt^$$&^dg#%o4Zwcat9knS)S#W'
short_wait: 8
common_blocks:
- &prod_my_pwd
name: MY_password
type xpath //*[@id="login-pwd"]: $my_pwd
click: xpath //*[@id="login-sub"]
wait: $short_wait
uitest:
- *prod_my_pwd
This is my gramextest script, where In the Yaml file where I am Reusing Configuration
The variable 'my_pwd' has $ symbol in it and to handle valueerror in the case if $ symbol available in the string I am adding $$ instead of $ (and the gramex -> config.py -> _substitute_variable() function handle this escaping of $ case value error)
but still in my script it failing and returning exception -> ValueError: Use $$ instead of $ in Ve5$&^fh#%o4Znjtv9kmH)H#W
So when I debug the gramex python function _substitute_variable() I got to know
- This is working fine at first place when I am calling/using variable
$my_pwd - But this is failing when I am Reusing the configuration which is -
*prod_my_pwd
And the reason why its failing at 2nd place is -
at the first time execution of $my_pwd it replacing its original value and storing the returned val of _substitute_variable() and hence at the place of Reusing configuration its not getting the original value (with $$) of 'my_pwd' and the function _substitute_variable() returning value error : ValueError: Use $$ instead of $ in Ve5$&^fh#%o4Znjtv9kmH)H#W
I am wondering how the $my_pwd loosing its original value and hence while Reusing configuration I am not getting original defined variable's value
Expected behavior: variable should not loose its original defined value while reusing unless and until its explicitly change/replace in script later
Environment:
- Gramex version: oldest to newest
┆Issue is synchronized with this Jira Bug
@nivedita-deshmukh -- I'm able to reproduce this with the following configuration
variables:
my_pwd: '$$&'
url:
a:
pattern: /a
handler: FunctionHandler
kwargs: &alpha
function: str
args: $my_pwd
b:
pattern: /b
handler: FunctionHandler
kwargs: *alpha
Gramex fails to start.
This is, unfortunately, rather hard to fix given the way Gramex is written at the moment. Can't promise a timeline. But this is definitely a bug -- thanks for highlighting!