I just got an error about an unexpected token while using the NiFi expression language.
'prod' validated against ${hostname:contains("prod")} is invalid because
Unexpected token ':' at line 1, column 10. Query: ${hostname:contains(prod)}
In this case the problem occurs in the RouteOnAttribute processor.
My question: What is/are the typical causes of this error?
Of course it is good to check the actual expression, however in this case I did not find any problems with the expression.
The problem comes from hostname
As documented here:
There also exist some functions that expect to have no subject. These functions are invoked simply by calling the function at the beginning of the Expression, such as ${hostname()}
After this it was quickly fixed by calling my attribute host_name instead.
Related
I have the following expression in YAML:
service: mqtt.publish
data:
topic: zigbee2mqtt/Bathroom_Dimmer/set
payload:{"brightness_step": 150-{{state_attr('light.Bathroom_Dimmer','brightness')|int}} }
It outputs:
Message 7 received on zigbee2mqtt/Bathroom_Dimmer/set at 10:07 PM:
{"brightness_step": 150-255}
How can I get it to output "-105" instead of "150-255"?
EDIT:
I think that automations in Home Assistant use the Jinja2 engine. The double brackets make it evaluate. So the problem was that the 150 was not in the brackets. Adding extra brackets did not work, so it seems they cannot be nested.
YAML is not code, so you can't expect a generalised behaviour of evaluating any kind of expression. It's up to the application that uses that data to decide what to do with it and you may find that some applications do support an expression syntax within YAML.
I'm guessing this is something to do with a ZigBee config file which I have never used, but I don't see any evidence that it supports expressions. Do you have any reason to believe that it does? If so, this behaviour comes from the application, not from YAML.
I have a query parameter defined in RAML as of type Integer and have used APIKit to generate flows and validation implementation. When I enter the invalid value 1]3 for this field, I get the following validation error, as expected:
"Invalid value '1]3' for query parameter offset. Invalid type String, expected Integer"
However, if I enter the single character ] I do not get a validation error, but it looks like this causes a fault in YAML parsing as the character is interpreted as YAML and not text to be validated.
"Invalid value ']' for query parameter offset. Underlying error while parsing YAML syntax: 'while parsing a block node
in 'reader', line 1, column 1:
]
^
expected the node content, but found ']'
To me both inputs should return the first error shown. This behaviour is also triggered by input of other YAML special characters such as : , ' and ,, where they are the only character entered in the query parameter.
So my question is, how can I get these error cases to return consistent format error messages - that is, of the first example, without mapping both to a custom Mule error? Passing the error text on to consumers as-is makes for an inconsistent user experience. Or perhaps this is not the intention, and these errors should always be mapped to a custom error?
Mule runtime version 4.3.0
APIKit version 1.4.1
I have the following element on an HTML page:
<option value="52">Engine Specialist</option>
I have a regular expression extractor giving me a variable named SpecialistInfo:
<option value="(\d+)">(.+?)<\/option>
JMeter gives me a match and I can access the matched values using the "group notation" syntax: SpecialistInfo_g1 and SpecialistInfo_g2
In a subsequent test I have a response assertion with a pattern of ${SpecialistInfo_g2} and I'm tyring to match against the following: "This person is an Engine Specialist"
This understandably fails with an assertion error: Assertion failure message:Test failed: text expected to contain /Engine Specialist/
I have tried using a matching pattern of: ${__unescapeHtml(${SpecialistInfo_g2})} which seems to replace the entity with a space but the match still fails.
The assertion error JMeter gives me is Assertion failure message:Test failed: text expected to contain /Engine Specialist/
Does anyone have suggestions on what to try?
My expectation is that __unescapeHtml() function produces something weird and not the space and hence your assertion fails.
Try using the following __groovy() function instead:
${__groovy(vars.get('SpecialistInfo_g2').replace(' '\, '\u0020'),)}
This will guaranteed return "normal" space separator hence your assertion should start working normally
I m trying to validate the image url using golang code but there is error in regular expression I'm showing my regular expression in this question:-
var validation = regexp.MustCompile("(http(s?):)|([/|.|\w|\s])*\.(?:jpg|gif|png)")
Error:-
unknown escape sequence (and 2 more errors)
play link
\. is an invalid escape sequence. I would suggest you use backticks when defining regular expressions. e.g.
regexp.MustCompile(`^https?://.*\.(jpg|gif|png)$`) // this will just check if the url ends with jpg,gif,png
If you are not using the capture groups, this is a simpler approach. However when parsing or validating URLs, use url.Parse() which provides better validation.
i'm trying to use the ApplySimple function in order to define a Metric in MicroStratey. My gloal is to cast a fact column to double value.
My current metric definition is:
ApplySimple("TO_DOUBLE(#0)", MYFACT)
The syntax check reports a wrong expression and indicates the error by marking the comma.
I tried to remove the MYFACT parameter including comma, but the syntax check fails as well, indicating the error on right parenthesis.
ApplySimple("TO_DOUBLE(MYFACT)")
Any suggentions on how to correct the syntax?
Thank you very much!
Kind regards
Okay, just got the problem. You have to use ";" insted of "," after the expression.