Skip to content

BUG: Web Clipper Interpreter leaves JSON escape sequences in output from pretty-printed JSON #947

Description

@Madhat69

Is this issue related to missing content or incorrect conversion to Markdown?

  • No. This is definitely a Web Clipper bug.

Have you reviewed the troubleshooting instructions?

Operating system

Windows 11 Pro 25H2 (Build 26200.9168)

Browser

Chrome 151.0.7922.174 (64-bit)

Web Clipper version

1.7.1

Obsidian version

1.13.7 Desktop

Describe the bug

When using Interpreter with a local model (Gemma 4 12B QAT, served via Unsloth Desktop's local OpenAI-compatible API), prompt variable output sometimes lands in the note with escape sequences intact — e.g. \\"hello\\" instead of "hello", and literal \n instead of real line breaks — instead of being rendered cleanly.

# Test

- \\"hello\\"
- \\"small reversible test\\"
- \\"delve\\" and \\"pivotal\\"

[Example Link](https://example.com)

I found a strong correlation with the formatting of the model's JSON response:

  • Compact, single-line JSON consistently produces correct Markdown in my testing.
  • Pretty-printed, indented JSON can result in the JSON escape sequences being written literally into the note.
    Both responses below are valid JSON and decode to the same prompt_1 string.

Example — compact JSON (works correctly):

{"prompts_responses":{"prompt_1":"# Test\n- \"hello\"\n- \"small reversible test\"\n- \"delve\" \"pivotal\"\n[Link](https://example.com)"}}

Example — pretty-printed JSON (breaks, shows literal backslashes in the note):

{
  "prompts_responses": {
    "prompt_1": "# Test\n- \"hello\"\n- \"small reversible test\"\n- \"delve\" \"pivotal\"\n[Link](https://example.com)"
  }
}

Both are valid JSON and decode to identical strings. This suggests the parsing/fallback logic isn't reliably handling the pretty-printed variant — possibly related to the code-fence-stripping + JSON.parse fallback flagged in #114, where a failed parse silently falls back to inserting the raw, unparsed response text.

Expected behavior

Interpreter should parse pretty-printed (indented) JSON responses the same as compact ones, since both are valid JSON.

For example, both responses above should result in:

# Test

- "hello"
- "small reversible test"
- "delve" "pivotal"

[Link](https://example.com)

No JSON escape characters should remain in the saved note.

URLs where the bug occurs

No response

To reproduce

  1. Set up a custom/local Interpreter provider (OpenAI-compatible endpoint) running a model that sometimes formats its JSON responses with indentation/line breaks (observed with Gemma 4 12B QAT).
  2. Use a template with this prompt variable:
{{"Create a heading called Test. Then create three bullet points. The first bullet must contain the word hello surrounded by double quotation marks. The second bullet must contain the phrase small reversible test surrounded by double quotation marks. The third bullet must contain two separately quoted words: delve and pivotal. Include one Markdown link to https://example.com. Do not add commentary."}}
  1. Run Interpreter until you get a pretty-printed response back (seems to depend on the model's own formatting choice, not a Web Clipper setting).
  2. Observe literal \" and \n in the resulting note instead of rendered quotes and line breaks.
  3. The behavior is intermittent with the same template and model. In one test series, 8/10 runs reproduced the problem and 2/10 succeeded.

Workaround
Appending "Respond with compact, single-line JSON only." to the end of the prompt reliably avoids the bug in my testing. Interpreter shouldn't depend on the model's formatting style to parse correctly, though.

Your template file

{
  "schemaVersion": "0.1.0",
  "name": "Template_Test",
  "behavior": "create",
  "noteContentFormat": "{{\"Create a heading called Test. Then create three bullet points. The first bullet must contain the word hello surrounded by double quotation marks. The second bullet must contain the phrase small reversible test surrounded by double quotation marks. The third bullet must contain two separately quoted words: delve and pivotal. Include one Markdown link to https://example.com. Do not add commentary.\"}}",
  "properties": [],
  "triggers": [],
  "noteNameFormat": "{{title}}",
  "path": "Clippings",
  "context": "{{content}}"
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions