Skip to content

Custom formatter shows false "not valid JSON" error despite producing correct output #1011

@river-walras

Description

@river-walras

Bug Description

The custom column formatter shows a false "Unexpected token '"', "" is not valid JSON" error in the editor even when the formatter is working correctly and producing valid output.

Repro Steps

  1. Open a table with a BLOB column containing JSON data stored as UTF-8 bytes (hex-encoded, e.g. 0x7b...)
  2. Click the column header menu → Format Column
  3. Select Create Custom Formatter
  4. Enter the following code:
(value) => {
  if (!value) return '';
  const hex = String(value).replace(/^0x/, '');
  const str = hex.match(/.{1,2}/g)
    .map(byte => String.fromCharCode(parseInt(byte, 16)))
    .join('');
  const parsed = JSON.parse(str);
  return `<pre><code>${JSON.stringify(parsed, null, 2)}</code></pre>`;
}
  1. Observe that the Output panel correctly renders the decoded JSON
  2. Observe that the editor header still shows: Unexpected token '"', "" is not valid JSON

Expected Behavior

No error should be shown when the formatter produces valid output. The error indicator should only appear if the formatter actually fails to execute or throws an exception.

Actual Behavior

The formatter works correctly — the Output panel displays properly formatted JSON — but the editor simultaneously shows a false positive error message, causing confusion about whether the formatter is valid.

Environment

  • DBCode version: 1.28.13
  • VS Code version: 1.110.1 (Universal)
  • OS: Macos
  • Database: SQLite
  • Connection: File (local)

Error Messages

Unexpected token '"', "" is not valid JSON
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions