Skip to content

API Error 400: "no low surrogate in string" when gstack captures pages with special Unicode characters #1440

@UlongChaS2

Description

@UlongChaS2

Bug Description

When using the gstack skill to capture or browse pages, the following error occurs intermittently:

API Error: 400 The request body is not valid JSON: no low surrogate in string: line 1 column 241447 (char 241446)

Root Cause

gstack serializes page content (DOM text, screenshots, etc.) and sends it to the Claude API as JSON. If the page
contains lone Unicode surrogate characters (unpaired \uD800–\uDFFF range), JSON serialization fails and the API rejects
the request with a 400 error.

Steps to Reproduce

  1. Use the gstack skill to browse or capture a page
  2. If the page contains special characters or emoji with lone surrogates, the error appears

Expected Behavior

gstack should sanitize or replace lone surrogate characters (e.g., replace with \uFFFD) before serializing to JSON.

Actual Behavior

The entire request fails with a 400 error and gstack cannot proceed.

Notes

  • The error position (column ~241447) suggests it occurs deep in a large payload, likely a base64-encoded screenshot or
    large DOM text
  • The user has no way to prevent or work around this — it requires a fix on the gstack side

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions