[ 
https://issues.apache.org/jira/browse/NIFI-15975?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18083557#comment-18083557
 ] 

Daniel Stieglitz edited comment on NIFI-15975 at 5/26/26 4:27 PM:
------------------------------------------------------------------

[~sammut97] I am not fully sure but somehow it looks like line 1 and 2 based on 
the compile error seems to be like one line which would like
{code:java}
let id = .value.idlet client_name = replace(.value.client_name, "-[^-]+$", 
""){{code}
and at column 35 there is an = sign. Once you put the space it now looks like
{code:java}
let id = .value.id let client_name = replace(.value.client_name, "-[^-]+$", 
""){{code}
which apparently is valid.


was (Author: JIRAUSER294662):
[~sammut97] I am fully sure but somehow it looks like line 1 and 2 based on the 
compile error seems to be like one line which would like
{code:java}
let id = .value.idlet client_name = replace(.value.client_name, "-[^-]+$", 
""){{code}
and at column 35 there is an = sign. Once you put the space it now looks like
{code:java}
let id = .value.id let client_name = replace(.value.client_name, "-[^-]+$", 
""){{code}
which apparently is valid.

> 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)

Reply via email to