sanity-io / assist

Sanity AI Assist: A plugin for Sanity Studio
MIT License
13 stars 5 forks source link

Sanity studio suddenly complains that AI Document is not a valid Document schema. Getting unexpected end of JSON input from Sanity Assist. #16

Closed miklschmidt closed 1 year ago

miklschmidt commented 1 year ago

If you find a security vulnerability, do NOT open an issue. Email security@sanity.io instead.

Describe the bug

Sanity AI assist stopped functioning earlier today. Actions result in nothing, and we're getting "Unexpected end of JSON input" in the Sanity AI Assist Status box.

image

Digging deeper, the AI Document schema doesn't seem to validate and results in a console.error entry that isn't immediately obvious. Overwriting console.error to inspect the state, we see that it's the AI Document that doesn't validate (using object in type instead of document, though this isn't new, so not sure why it's complaining now):

image

To Reproduce

Steps to reproduce the behavior:

  1. Login to a studio with sanity assist enabled. This happens locally as well as online on *.sanity.studio which hasn't been deployed in weeks in our case.
  2. Schema error should already be present in the console
  3. Run an instruction, notice that nothing happens after it finishes.
  4. Observe the unexpected end of JSON error in the assist status box

Expected behavior

Instruction should apply the results, AI Document schema shouldn't cause a schema type error.

Screenshots See above.

Which versions of Sanity are you using? This happens on the newest versions:

@sanity/cli (global)                   3.19.2 (up to date)
@sanity/assist                         1.2.13 (up to date)
@sanity/code-input                      4.1.1 (up to date)
@sanity/dashboard                       3.1.5 (up to date)
@sanity/document-internationalization   2.0.2 (up to date)
@sanity/eslint-config-studio            3.0.1 (up to date)
@sanity/vision                         3.19.2 (up to date)
sanity                                 3.19.2 (up to date)

But was initially observed on:

@sanity/cli (global)                   3.16.4 (latest: 3.19.2)
@sanity/assist                          1.2.5 (latest: 1.2.13)
@sanity/code-input                      4.1.1 (up to date)
@sanity/dashboard                       3.1.5 (up to date)
@sanity/document-internationalization   2.0.1 (latest: 2.0.2)
@sanity/eslint-config-studio            3.0.1 (up to date)
@sanity/vision                         3.16.4 (latest: 3.19.2)
sanity                                 3.16.4 (latest: 3.19.2)

What operating system are you using? Windows 11 / WSL

Which versions of Node.js / npm are you running?

$ npm -v && node -v && yarn -v 
9.6.7
v18.17.1
1.22.19
snorrees commented 1 year ago

Hey, this turned out to be caused by a recent breaking change in the third party APIs used by AI Assist. This has now been fixed in the backend (from whence the JSON parse error came).