Describe the bug
When using Sanity AI Assist, using an instruction that "changes the document", we've seen that it entered a numerical value into an orderRank field. Instead of 0|00001, Sanity AI Assist inserted 1. This crashed the entire Sanity application with the following error:
Error: undefined is not an object (evaluating 'n.indexof')
parse@https://vev-cms.sanity.studio/static/sanity-9d8b5920.js:6932:288611
parse@https://vev-cms.sanity.studio/static/sanity-9d8b5920.js:6932:296693
JF3@https://vev-cms.sanity.studio/static/sanity-9d8b5920.js:8375:34507
Debugging step by step showed that orderRank field is expected to be a string. Since we have not defined newItemPosition, it defaults to after, which triggers a query to find the highest order rank to use for initialValue. Since this happens upon loading the schema, the entire application fails to start.
To Reproduce
Have a schema that has orderRank field, and newItemPosition not enabled
Create two document
In the most recently created document, use Sanity AI Assist to translate all fields in the document to some language (or manually set the orderRank field value to 1 if using Sanity AI to reproduce is too difficult).
Observe that the Sanity application crashes
Expected behavior
The application not to crash.
Possible remediations
The orderRankField to have options: { aiAssist: { exclude: true } } defined
Maybe some hardening against unexpected values in the orderRank field
Screenshots
Which versions of Sanity are you using?
@sanity/cli (global) 3.32.0 (up to date)
@sanity/assist 2.0.2 (latest: 2.0.3)
@sanity/color-input 3.1.1 (up to date)
@sanity/orderable-document-list 1.2.1 (up to date)
@sanity/ui 2.0.7 (latest: 2.0.10)
@sanity/vision 3.32.0 (up to date)
sanity 3.32.0 (up to date)
What operating system are you using?
MacOS
Which versions of Node.js / npm are you running?
v20.9.0
Describe the bug When using Sanity AI Assist, using an instruction that "changes the document", we've seen that it entered a numerical value into an
orderRank
field. Instead of0|00001
, Sanity AI Assist inserted1
. This crashed the entire Sanity application with the following error:Debugging step by step showed that orderRank field is expected to be a string. Since we have not defined
newItemPosition
, it defaults toafter
, which triggers a query to find the highest order rank to use forinitialValue
. Since this happens upon loading the schema, the entire application fails to start.To Reproduce
orderRank
field, andnewItemPosition
not enabled1
if using Sanity AI to reproduce is too difficult).Expected behavior
Possible remediations
orderRankField
to haveoptions: { aiAssist: { exclude: true } }
definedScreenshots
Which versions of Sanity are you using?
@sanity/cli (global) 3.32.0 (up to date) @sanity/assist 2.0.2 (latest: 2.0.3) @sanity/color-input 3.1.1 (up to date) @sanity/orderable-document-list 1.2.1 (up to date) @sanity/ui 2.0.7 (latest: 2.0.10) @sanity/vision 3.32.0 (up to date) sanity 3.32.0 (up to date)
What operating system are you using? MacOS
Which versions of Node.js / npm are you running? v20.9.0