appsmith icon indicating copy to clipboard operation
appsmith copied to clipboard

[Bug]: Passing a string with a lone closing curly brace breaks the params object

Open LagunaElectric opened this issue 1 year ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Description

When you pass an object with a string property containing a lone closing curly brace } to query.run() it breaks the params object. This causes it to evaluate to the string "undefined}" instead of an object. You can see this even with Use prepared statements on.

Steps To Reproduce

I'm using Postgres but any datasource should work. Here's my curly_break query:

SELECT '{{this.params.str}}' as res, '{{this.params.control}}' as control, '{{this.params}}' as params

This is my Test JS Object code:

export default {
	debug: async () => {
		const params = {
			str: 'testing',
			control: 'Hello, World!'
		}
		await curly_break.run(params)
		return curly_break.data[0]
	}
}

Running the debug function gives this result:

{
  "res": "testing",
  "control": "Hello, World!",
  "params": "{\"str\":\"testing\",\"control\":\"Hello, World!\"}"
}

Repro

For the tests I changed str but left control unmodified.

str = "{}"

{
  "res": "{}",
  "control": "Hello, World!",
  "params": "{\"str\":\"{}\",\"control\":\"Hello, World!\"}"
}

str = "}"

{
  "res": "null",
  "control": "null",
  "params": "undefined}"
}

str = "{"

{
  "res": "{",
  "control": "Hello, World!",
  "params": "{\"str\":\"{\",\"control\":\"Hello, World!\"}"
}

str = "{}}"

{
  "res": "null",
  "control": "null",
  "params": "undefined}"
}

str = "{{}"

{
  "res": "{{}",
  "control": "Hello, World!",
  "params": "{\"str\":\"{{}\",\"control\":\"Hello, World!\"}"
}

Public Sample App

No response

Environment

Production

Severity

Medium (Frustrating UX)

Issue video log

No response

Version

Cloud v1.40.0-SNAPSHOT

LagunaElectric avatar Sep 06 '24 21:09 LagunaElectric