You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document that Get Variable Value and Variable Should (Not) Exist do not support named-argument syntax #5235
I noticed that I am not able to pass default argument for Get Variable Value from BuiltIn as keyword argument. I.e. the following does not provide expected result: ${result} BuiltIn.Get Variable Value ${MY_VARIABLE} default=My Default
One would expect ${result} to have My Default as return if ${MY_VARIABLE} does not exist. Instead default=My Default is returned.
I didn't find any notion of this functionality anywhere and if the keyword works as expected, I would assume that this was mentioned in the documentation.
The decorator @run_keyword_variant(resolve=0) atop the get_variable_value implementation ensures a NullArgumentResolver is used intead of a NamedArgumentResolver. Thus the entire string is handled as a value (positional parameter). Seems by design (I don't know). The docstring indicates correctly.
@a-matta is right about why this happens. The mentioned @run_keyword_variant decorator is used to tell Robot not to replace variables in arguments. The reason why it's done is that otherwise using this keyword with a non-existing variable would fail already when arguments would be resolved.
I'm not sure has it even occurred to me earlier that not resolving arguments also disables the named argument syntax. That's rather annoying and should be fixed. The whole system for marking arguments not to be resolved is pretty bad and we have #2190 about fixing that. I'll add a comment to that issue about this problem.
Because the problem won't be fixed in the near future, I believe it's best to document this behavior in the keyword documentation. I'll check are there other keywords in BuiltIn that would need such a note as well.
changed the title [-]"Get Variable Value" does not support keyword argument for "default"[/-][+]Document that `Get Variable Value` and `Variable Should (Not) Exist` do not support named-argument syntax[/+]on Oct 16, 2024
Variable Should Exist and Variable Should Not Exist have a similar situation with their message argument. Also some other keywords are possibly affected, but I doubt they'd in general be used with the named-argument syntax anyway.
As #5025 demonstrated, various other keywords had the same problem. Instead of adding a note about this to all their docs, I decided to explicitly mark these arguments positional-only. That was done also to keywords that got a note to their docs as part of this issue. Notes were preserved otherwise, but the comment about us hopefully fixing the limitation in the future was removed.
Activity
a-matta commentedon Oct 13, 2024
The decorator
@run_keyword_variant(resolve=0)atop theget_variable_valueimplementation ensures aNullArgumentResolveris used intead of aNamedArgumentResolver. Thus the entire string is handled as a value (positional parameter). Seems by design (I don't know). The docstring indicates correctly.https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Get%20Variable%20Value

Seems the intention is to use this without the
default=prefix.¯\_(ツ)_/¯pekkaklarck commentedon Oct 16, 2024
@a-matta is right about why this happens. The mentioned
@run_keyword_variantdecorator is used to tell Robot not to replace variables in arguments. The reason why it's done is that otherwise using this keyword with a non-existing variable would fail already when arguments would be resolved.I'm not sure has it even occurred to me earlier that not resolving arguments also disables the named argument syntax. That's rather annoying and should be fixed. The whole system for marking arguments not to be resolved is pretty bad and we have #2190 about fixing that. I'll add a comment to that issue about this problem.
Because the problem won't be fixed in the near future, I believe it's best to document this behavior in the keyword documentation. I'll check are there other keywords in BuiltIn that would need such a note as well.
[-]"Get Variable Value" does not support keyword argument for "default"[/-][+]Document that `Get Variable Value` and `Variable Should (Not) Exist` do not support named-argument syntax[/+]pekkaklarck commentedon Oct 16, 2024
Variable Should ExistandVariable Should Not Existhave a similar situation with theirmessageargument. Also some other keywords are possibly affected, but I doubt they'd in general be used with the named-argument syntax anyway.Add notes about some BuiltIn keywords not supporting named arguments.
pekkaklarck commentedon Aug 27, 2025
As #5025 demonstrated, various other keywords had the same problem. Instead of adding a note about this to all their docs, I decided to explicitly mark these arguments positional-only. That was done also to keywords that got a note to their docs as part of this issue. Notes were preserved otherwise, but the comment about us hopefully fixing the limitation in the future was removed.