Skip to content

🐛 Bug: JSON_EXTRACT in formula with a special character fails #12377

@imajus

Description

@imajus

Please confirm that the bug report does not already exist

  • I confirm there is no existing issue for this bug.

Steps to reproduce

I am having an issue with a formula field that uses the 'JSON_EXTRACT' function. When I try to save the field, the system does not allow this and instead displays the following error: "Formula error: unsupported Unicode escape sequence".

My formula is quite simple:

JSON_EXTRACT({Metadata}, ".name")

Here's the backend log output:

error: select CASE WHEN (("p8ddrqb7p1oiybw"."mytable"."Metadata")::text )::jsonb IS NOT NULL THEN jsonb_path_query_first((("p8ddrqb7p1oiybw"."mytable"."Metadata")::text )::jsonb, CONCAT('$', '.name' )::jsonpath) ELSE NULL END as "__dry_run_alias" from "p8ddrqb7p1oiybw"."mytable" - unsupported Unicode escape sequence
at Parser.parseErrorMessage (/usr/src/app/node_modules/pg-protocol/dist/parser.js:283:98)
at Parser.handlePacket (/usr/src/app/node_modules/pg-protocol/dist/parser.js:122:29)
at Parser.parse (/usr/src/app/node_modules/pg-protocol/dist/parser.js:35:38)
at Socket.<anonymous> (/usr/src/app/node_modules/pg-protocol/dist/index.js:11:42)
at Socket.emit (node:events:518:28)
at Socket.emit (node:domain:489:12)
at addChunk (node:internal/streams/readable:561:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
at Readable.push (node:internal/streams/readable:392:5)
at TCP.onStreamRead (node:internal/stream_base_commons:189:23) {
length: 214,
severity: 'ERROR',
code: '22P05',
detail: '\\u0000 cannot be converted to text.',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: 'JSON data, line 1: ..."string","default":"","placeholder":"e.g., \\u0000...',
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'jsonfuncs.c',
line: '645',
routine: 'json_errsave_error'
}
NcBaseErrorv2: Formula error: unsupported Unicode escape sequence
at NcError.formulaError (/usr/src/app/docker/main.js:1553:42460)
at v (/usr/src/app/docker/main.js:272:30345)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async ColumnsService.columnUpdate (/usr/src/app/docker/main.js:1752:379303)
at async ColumnsController.columnUpdate (/usr/src/app/docker/main.js:184:38580) {
error: 'FORMULA_ERROR',
code: 400,
details: undefined
}

The field is not new; it used to work. However, since a record containing that special character was added to the JSON content, the field has stopped working. Now, it fails to render values for all records at once because of this.

Desired Behavior

The unsupported characters should either be escaped or removed from the data before it is written to the database.

Project Details

Node: v22.14.0
Arch: x64
Platform: linux
Docker: true
RootDB: pg
PackageVersion: 0.262.5

Attachments

Image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions