Skip to content

Fail closed when wizard JSON bodies do not parse - #132

Merged
cursor[bot] merged 1 commit into
mainfrom
cursor/wizard-json-parse-2ccd
Sep 7, 2026
Merged

cursor[bot] merged 1 commit into
mainfrom
cursor/wizard-json-parse-2ccd

Conversation

@jmjava

@jmjava jmjava commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Problem

request_json_object used Flask get_json(silent=True). Missing bodies and invalid JSON both returned None, which became {}. A POST of {not-json looked like an empty object and could write .docgen-state.json. JSON null was also treated as a missing body.

Change

Parse the raw request bytes with json.loads. Empty / whitespace-only bodies stay {}. Invalid JSON raises WizardError. JSON null is rejected as a non-object (same as a list).

Tests

  • Invalid JSON POST /api/state → 400, file not written
  • JSON null → 400
  • Empty body still succeeds as {}

Out of scope

  • Wizard except Exception around narration_topic_label
Open in Web Open in Cursor 

get_json(silent=True) returned None for both a missing body and garbage
JSON, so {not-json looked like {}. Parse the raw body; invalid JSON and
JSON null raise WizardError. Empty bodies stay {}.

Co-authored-by: jmjava <jmjava@gmail.com>
@jmjava
jmjava marked this pull request as ready for review September 7, 2026 23:28
@cursor
cursor Bot merged commit 5bc68dc into main Sep 7, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants