[
https://issues.apache.org/jira/browse/NIFI-15975?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18083564#comment-18083564
]
Jordan Sammut commented on NIFI-15975:
--------------------------------------
[~dstiegli1] ok i see, so it seems like spaces are not being honored right?
Have you recreated the issue on your end too by any chance please?
> JSLTTransformJSON Processor flagging errors on valid JSLT
> ---------------------------------------------------------
>
> Key: NIFI-15975
> URL: https://issues.apache.org/jira/browse/NIFI-15975
> Project: Apache NiFi
> Issue Type: Bug
> Reporter: Jordan Sammut
> Priority: Critical
>
> I am noticing some inconsistencies when it comes to the JSLTTransformJSON
> when validating the JSLT expression:
> *Example 1*
> {code:java}
> let is_valid_record =
> (.value.action == "tags")let pass = if($is_valid_record)
> let customer_id = .value.user_id
> let client_name = replace(.value.client_name, "-[^-]+$", "")
> let updated_at = format-time(number(.value.version), "yyyy-MM-dd
> HH:mm:ss.SSS", "UTC") {
> "key": $client_name + "/" + $customer_id,
> "metadata": {
> "topic": "customer_tag.cl1." + $client_name + ".v1"
> },
> "value": { "customer_id": $customer_id,
> "client_name": $client_name,
> "message_id": .value.msg_id,
> "updated_at": $updated_at,
> "tags": .value.tags,
> "api_version": .value.api_version, "source_kafka_timestamp":
> format-time(number(.metadata.timestamp) / 1000, "yyyy-MM-dd HH:mm:ss.SSS",
> "UTC"),
> "nifi_captured_at": format-time(now(), "yyyy-MM-dd HH:mm:ss.SSS",
> "UTC")
> }
> }
> else
> null
> $pass{code}
> The above transformation seems to compile with no issues, however if I had to
> add a comment at the very first line, Example "// Test", the compilation
> fails with the following error:
> "'JSLT Transformation' is invalid because JSLT Transformation not valid: Read
> JSLT Transform failed"
> *Example 2:*
> {code:java}
> let id = .value.id
> let client_name = replace(.value.client_name, "-[^-]+$", ""){
> "key": $client_name + "/" + $id,
> "metadata": {
> "topic": "group.cl1." + $client_name + ".v1"
> },
> "value": {
> "client_name": $client_name,
> "id": $id,
> "name": .value.name,
> "operation": .value.operation,
> "enabled": .value.enabled,
> "api_version": .value.api_version,
> "message_id": .value.msg_id,
> "source_kafka_timestamp": format-time(number(.metadata.timestamp) / 1000,
> "yyyy-MM-dd HH:mm:ss.SSS", "UTC"),
> "nifi_captured_at": format-time(now(), "yyyy-MM-dd HH:mm:ss.SSS",
> "UTC")
> }
> } {code}
> The above is a valid JSLT but is returning the following error on compilation:
> "'JSLT Transformation' is invalid because JSLT Transformation not valid:
> Parse error: Encountered " "=" "= "" at line 1, column 35. Was expecting: "("
> ... at <inline>:1:23"
> Simple adding a space at line 2 fixes it though:
> {code:java}
> let id = .value.id
> let client_name = replace(.value.client_name, "-[^-]+$", ""){
> "key": $client_name + "/" + $id,
> "metadata": {
> "topic": "group.cl1." + $client_name + ".v1"
> },
> "value": {
> "client_name": $client_name,
> "id": $id,
> "name": .value.name,
> "operation": .value.operation,
> "enabled": .value.enabled,
> "api_version": .value.api_version,
> "message_id": .value.msg_id,
> "source_kafka_timestamp": format-time(number(.metadata.timestamp) / 1000,
> "yyyy-MM-dd HH:mm:ss.SSS", "UTC"),
> "nifi_captured_at": format-time(now(), "yyyy-MM-dd HH:mm:ss.SSS",
> "UTC")
> }
> } {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)