Relevance substitution - double doublequote issues

I want to use a relevance statement like the following in an if or continue if statement in my action script where the parameters are entered through action parameter queries but I can’t seem to get the double doublequotes to work using many different versions. Here’s the stripped down version of what I’m trying to do.

action parameter query "pgkname" with description "Enter the name of the package to be updated:" with default "<Enter package name>"
action parameter query "pgkver" with description "Enter the new minimum package version.  All versions below this version will be updated to this version:" with default "<min package version>"

continue if {exists package parameter "pkgname" of rpm and version of package parameter "pkgname" of rpm is less than parameter "pkgver"}
wait /bin/bash -c "dnf update -y {parameter "pkgname"}"

I tried entering the quotes in the parameter query as described in the Note on this page using %22 %22, similar to here, but that doesn’t seem to do the trick. Maybe I’m missing something? Is there a way to do this?

Try this slight change, the other looks ok. What do you see in the agent log file when you execute?

continue if {exists package (parameter "pkgname") whose (exists version of it) of rpm and version of package (parameter "pkgname") of rpm < (parameter "pkgver" as version)}

1 Like

No change, I keep getting the same result in the client log:

Command succeeded action parameter query “pgkname” with description “Enter the name of the package to be updated:” with default “” (action:2558)
Command succeeded action parameter query “pgkver” with description “Enter the new minimum package version. All versions below this version will be updated to this version:” with default “” (action:2558)
Command failed (Relevance substitution failed) continue if {exists package (parameter “pkgname”) whose (exists version of it) of rpm and version of package (parameter “pkgname”) of rpm < (parameter “pkgver” as version)} (action:2558)

In the emsg log I get the following:
Tue, 03 Oct 2023 23:42:44 -0400 DebugMessage RelevanceSubstitution::EvaluateRelevanceAsString() error DebuggableException: 20ArgumentDoesNotExist
Tue, 03 Oct 2023 23:42:44 -0400 DebugMessage RelevanceSubstitution::SubstituteStrings() error, returning false
Tue, 03 Oct 2023 23:42:44 -0400 DebugMessage Command failed (Relevance substitution failed) continue if {exists package (parameter “pkgname”) whose (exists version of it) of rpm and version of package (parameter “pkgname”) of rpm < (parameter “pkgver” as version)} (action:2558)

Please check the following thread - Relevance substitution error - Running OK on the Fixlet Debugger

I had similar issue
Make sure you don’t fall for that issue

1 Like

You have a typo in your action script. Check your parameter name and the continue if parameter names.

4 Likes

Thank you, vk! I’ve fixed the typo but still not having any success…
from the client log:

Command succeeded action parameter query "pkgname" with description "Enter the name of the package to be updated:" with default "<Enter package name>" (action:2562) 

Command succeeded action parameter query "pkgver" with description "Enter the new minimum package version.  All versions below this version will be updated to this version:" with default "<max package version>" (action:2562)

Command failed (Relevance substitution failed) continue if {exists packages parameter "pkgname" of rpms and version of packages parameter "pkgname" of rpms is less than parameter "pkgver"} (action:2562)

I tried leaving out the continue if statement just to reduce the number of places where failure could occur. I also tried with and without adding %22"pkgname"%22 around the parameter like…

action parameter query "pkgname" with description "Enter the name of the package to be updated:" with default "<Enter package name>"
action parameter query "pkgver" with description "Enter the new minimum package version.  All packages below this version will be updated to this version:" with default "<min package version>"

wait /bin/bash -c "dnf update -y {parameter %22"pkgname"%22}"

with the same results:

   Command succeeded action parameter query "pkgname" with description "Enter the name of the package to be updated:" with default "<Enter package name>" (action:2562)
   Command succeeded action parameter query "pkgver" with description "Enter the new minimum package version.  All versions below this version will be updated to this version:" with default "<max package version>" (action:2562)
   Command failed (Relevance substitution failed) continue if {exists packages parameter "pkgname" of rpms and version of packages parameter "pkgname" of rpms is less than parameter "pkgver"} (action:2562)

and

   Command succeeded action parameter query "pkgname" with description "Enter the name of the package to be updated:" with default "<Enter package name>" (action:2563)
   Command succeeded action parameter query "pkgver" with description "Enter the new minimum package version.  All packages below this version will be updated to this version:" with default "<min package version>" (action:2563)
   Command failed (Relevance substitution failed) wait /bin/bash -c "dnf update -y {parameter %22"pkgname"%22}" (action:2563)

So, one really useful thing you can to is to force the client log to show what the relevance statement looks like after substitutions. Try this, the logfile should show some some useful things to troubleshoot

action parameter query "pkgname" with description "Enter the name of the package to be updated:" with default "<Enter package name>"

action parameter query "pkgver" with description "Enter the new minimum package version.  All packages below this version will be updated to this version:" with default "<min package version>"

delete __appendfile

appendfile {parameter "pkgname"} {parameter "pkgver"}

When you’re using the parameters directly in Relevance, you should not have to string-quote the values, but you may need to wrap in parentheses, i.e.

continue if {exists packages (parameter "pkgname") of rpms and version of packages (parameter "pkgname") of rpms is less than (parameter "pkgver")}

In your ‘wait’ line, you’re trying to use the %22 outside of a string. You could write this in a couple of ways - either

wait /bin/bash -c "dnf update -y {"%22" & parameter "pkgname" & "%22"}"

or just leave the quotes outside of the relevance. But since the bash command line has doublequotes, you can’t use the same doublequotes in the package name - the generated command would not evaluate correctly by bash if it’s

wait /bin/bash -c "dnf update -y "BESAgent""

instead replace at least one set of doublequotes with singlequotes

wait /bin/bash -c 'dnf update -y "{parameter "pkgname"}"'

Or, you can escape the embedded doublequotes around the package name with backslashes

wait /bin/bash -c "dnf update -y \"{parameter "pkgname"}\""
4 Likes

Using the appendfile to view the parameter values as they are being passed is a useful tool, it confirmed that they were being passed correctly.

The ‘continue if’ line works using the parenthesis around each parameter.

The ‘wait’ line needed the double quotes around the entire dnf command so the second option using the backslashes did the trick.

Command succeeded action parameter query "pkgname" with description "Enter the name of the package to be updated:" with default "<Enter package name>" (action:2570)
   Command succeeded action parameter query "pkgver" with description "Enter the new minimum package version.  All packages below this version will be updated to this version:" with default "<min package version>" (action:2570)
   Command succeeded delete __appendfile (action:2570)
   Command succeeded appendfile {parameter "pkgname"} {parameter "pkgver"} (action:2570)
   Command succeeded (file created) appendfile 1password 8.10.16-1 (action:2570)
   Command succeeded appendfile 1password 8.10.16-1 (action:2570)
   Command succeeded (evaluated true) continue if {exists packages (parameter "pkgname") of rpms and version of packages (parameter "pkgname") of rpms is less than (parameter "pkgver")} (action:2570)
   Command started - wait /bin/bash -c "dnf update -y \"1password\"" (action:2570)
Command succeeded (Exit Code=0) wait /bin/bash -c "dnf update -y \"1password\"" (action:2570)

Thank you @JasonWalker and everyone who pitched in.

2 Likes