improve contextual json deserializing error feedback, Syntax Error, invalid Expression

Description

When a json deserializing error occurs, the error message is rather confusing

https://trycf.com/gist/92ed093b8d46ff052b27929eb479930b/lucee5?theme=monokai

when the source text is longer than 1024 characters, only the first snippet 1024 characters are shown, the cfml object includes the position in the string, so the error message snippet sometimes doesn’t even include the actual problematic content.

as actual error includes the character position, provide better contextual feedback (i.e. offset and snippet)

i.e. Syntax Error, invalid expression [7D]

also when a sub snippet is provided, indication that it’s sub snippet , ...] would be quite informative

<cfscript> x = '{ content: "#repeatString('a ',505)#" }7D'; </cfscript> <cfscript> try { j = ""; j = deserializeJson(x); } catch (e) { echo(e); } dump(j); </cfscript>

this screenshot shows with 495 repeated strings, rather than 505, so the preview of the source string fits in the screenshot

https://github.com/lucee/Lucee/blob/5.3/core/src/main/java/lucee/runtime/interpreter/CFMLExpressionInterpreter.java#L215

Attachments

3
  • 09 Jun 2023, 10:59 am
  • 10 Oct 2022, 11:10 am
  • 10 Oct 2022, 11:05 am

Activity

Pothys - MitrahSoft 9 June 2023 at 10:56
Edited

I’ve checked this ticket with lucee version Lucee 6.0.0.447-SNAPSHOT. Now the error Message include the position of the string and error detail shows fine.

Zac Spitzer 26 May 2023 at 13:47

I also moved the snippet for a short json string to the detail, as it might reveal information which shouldn’t be visible in the exception message

Zac Spitzer 26 May 2023 at 11:44

Syntax Error, invalid Expression [7] at position [25 ] in [{ content: "a a a a a " }7D]

https://github.com/lucee/Lucee/pull/2083

Fixed

Details

Assignee

Reporter

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Fix versions

Priority

Created 10 October 2022 at 11:05
Updated 20 June 2024 at 20:16
Resolved 9 June 2023 at 10:59