Hi,
I am building a custom snap where some of the fields need to be a ‘textarea’ type. I’ve been searching through the documentation but didn’t find anything related to this.
Is there a way to make the field a text area ?
I am looking for something like the private/public keys in the account of a PGP Encrypt snap where the inputs are text area types.
On the image below, the input types are different from the ‘Key pasphrase’ which is of an ‘input’ type but the private and public keys are of ‘text area’ type.
@ptaylor Any suggestions please ?
2 Likes
Yes: call .uiRowCount(int)
when building the property.
Thank you, that works, however I am unable to properly parse the value from the field ?
Does it return a string or something else ?
Here’s what I have:
...
private static final String PRIVATE_KEY = "Private key";
private static final String PUBLIC_KEY = "Public key";
...
private String privateKey; // This is used to capture the value from the private key property
private String publicKey; // This is used to capture the value from the public key property
Then the defineProperties method:
...
propertyBuilder.describe(PRIVATE_KEY, "Private key")
.required()
.uiRowCount(10)
.add();
propertyBuilder.describe(PUBLIC_KEY, "Public key")
.uiRowCount(10)
.add();
...
Then the configure method:
@Override
public void configure(PropertyValues propertyValues) {
...
privateKey = propertyValues.get(PRIVATE_KEY);
publicKey = propertyValues.get(PUBLIC_KEY);
...
}
This is how the snap looks like with the properties:
However, when the pipeline is executed with the snap included, it returns the following error:
Snap has the following errors.
Please open the info box and edit the highlighted fields.
* Failure: Private key: asdasd is undefined.
Perhaps you meant: task, Base64, parseFloat, parseInt,
Reason: Snap failed unexpectedly and did not provide any reason,
Resolution: Check the spelling of the variable
Is it because .uiRowCount(int) returns a different type than String, so it is not able to parse it correctly in the configure() method ?
Please open the Pipeline Statistics, expand the details, copy the stack trace and paste it here.
do share the full body of the configure() method.
@ptaylor
SnapCompletionService
com.snaplogic.snap.api.SnapDataException: Public key: asdasd is undefined. Perhaps you meant: task, Base64, parseFloat, parseInt
at com.snaplogic.snap.api.impl.PropertyValuesImpl$ValidatingExpressionProperty.eval(PropertyValuesImpl.java:1056)
at com.snaplogic.snap.api.impl.PropertyValuesImpl$ValidatingExpressionProperty.eval(PropertyValuesImpl.java:993)
at com.iwconnect.snaps.GPGAccount.getPublicKey(GPGAccount.java:124)
at com.iwconnect.snaps.GPGEncrypt$1.write(GPGEncrypt.java:112)
at com.snaplogic.cc.snap.view.binary.BinaryOutputViewImpl.write(BinaryOutputViewImpl.java:239)
at com.snaplogic.snap.api.OutBoundViewsImpl.write(OutBoundViewsImpl.java:287)
at com.iwconnect.snaps.GPGEncrypt.process(GPGEncrypt.java:94)
at com.iwconnect.snaps.GPGEncrypt.doWork(GPGEncrypt.java:81)
at com.snaplogic.snap.api.SimpleBinarySnap.execute(SimpleBinarySnap.java:57)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.executeSnap(SnapRunnableImpl.java:812)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.execute(SnapRunnableImpl.java:586)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.doRun(SnapRunnableImpl.java:877)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:436)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:120)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Resolution: Check the spelling of the variable
Error Fingerprint[0] = efp:com.snaplogic.snap.api.impl.lsG7vC2t
@smudassir
@Override
public void configure(PropertyValues propertyValues) {
passphrase = propertyValues.getAsExpression(PASSPHRASE);
privateKey = propertyValues.get(PRIVATE_KEY);
publicKey = propertyValues.get(PUBLIC_KEY);
symmetricAlgorithmType = propertyValues.get(ALGORITHM);
}
The passphrase/symmetrycAlgorithmType are successfully parsed as strings. The privateKey, publicKey work fine if I remove the .uiRowCount(int) and parse them as String values for example. I am not sure if .uiRowCount(int) is the issue ?
It looks like GPGAccount.getPublicKey()
is evaluating the public key property as an expression even though it’s not defined as an expression. Please take a closer look at that method or share it here.
@ptaylor
Sorry that’s the error message when I had the field as an expression property. This is the actual stacktrace ( the property is defined as a String and then the .get(PROPERTY_NAME) is used in the configure() method ):
SnapCompletionService
com.snaplogic.snap.api.SnapDataException: Private key: asdasd is undefined. Perhaps you meant: task, Base64, parseFloat, parseInt
at com.snaplogic.snap.api.impl.PropertyValuesImpl$ValidatingExpressionProperty.eval(PropertyValuesImpl.java:1056)
at com.snaplogic.snap.api.impl.PropertyValuesImpl$ValidatingExpressionProperty.eval(PropertyValuesImpl.java:993)
at com.snaplogic.snap.api.impl.PropertyValuesImpl.getValueFor(PropertyValuesImpl.java:741)
at com.snaplogic.snap.api.impl.PropertyValuesImpl.getValueFor(PropertyValuesImpl.java:679)
at com.snaplogic.snap.api.impl.PropertyValuesImpl.getValueFor(PropertyValuesImpl.java:669)
at com.snaplogic.snap.api.impl.PropertyValuesImpl.get(PropertyValuesImpl.java:656)
at com.snaplogic.snap.api.impl.PropertyValuesImpl.get(PropertyValuesImpl.java:593)
at com.iwconnect.snaps.GPGAccount.configure(GPGAccount.java:100)
at com.snaplogic.cc.util.SnapUtil.configure(SnapUtil.java:374)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.configureSnap(SnapRunnableImpl.java:732)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.execute(SnapRunnableImpl.java:585)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.doRun(SnapRunnableImpl.java:877)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:436)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:120)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Resolution: Check the spelling of the variable
Only the passphrase is used as an expression and it works fine, however, the private key and public key do not work as expected.
public String getPassphrase() {
return passphrase.eval(null).toString();
}
public String getPrivateKey() {
return privateKey;
}
public String getPublicKey() {
return publicKey;
}
I’m confused by that stack trace since the line numbers for PropertyValuesImpl.java don’t correspond to the current version of the code, which hasn’t changed in months. What version of the platform are you using?
Also, have you tried restarting your node since changing the property from an expression to not an expression? I’ve seen issues where the platform caches some metadata about property definitions and the cache won’t reset unless you restart the process.
Actually, that stack trace corresponds to the state of the code prior to August 2021. So that’s really odd. In which environment is this happening?
@ptaylor
I am using version 4.32 GA. I have also tried restarting the node but it doesn’t work as well. It works if I switch the field to expression property and remove the .uiRowCount(int).
As for the env, what exactly do you mean by this ? Are you referring to the organization or to the env type ? The env is on a production env. ( same version 4.32 GA ).
I suspect there is a problem with how you’re building your snap pack and perhaps you’re including some outdated version of the SDK in the snap pack itself.
Please email me your pom.xml: ptaylor@snaplogic.com
BTW, I can’t reproduce this issue. I have a string property that’s not an expression with uiRowCount(5) and it works just fine.
Can you upload your GPGAAccount.java here?